Skip to content

Commit d7dc334

Browse files
committed
more tyepsafe logging
1 parent 306684f commit d7dc334

File tree

6 files changed

+30
-12
lines changed

6 files changed

+30
-12
lines changed

hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.hibernate.engine.spi.CollectionEntry;
2020
import org.hibernate.internal.log.SubSystemLogging;
2121

22+
import org.hibernate.tool.schema.spi.CommandAcceptanceException;
23+
import org.hibernate.tool.schema.spi.GenerationTarget;
2224
import org.jboss.logging.BasicLogger;
2325
import org.jboss.logging.Logger;
2426
import org.jboss.logging.annotations.Cause;
@@ -311,6 +313,10 @@ void missingArguments(
311313
@Message(value = "Unsuccessful: %s", id = 478)
312314
void unsuccessfulSchemaManagementCommand(String command);
313315

316+
@LogMessage(level = DEBUG)
317+
@Message( value = "Error performing delayed DROP command [%s]", id = 479 )
318+
void unsuccessfulDelayedDropCommand(CommandAcceptanceException e);
319+
314320
@LogMessage(level = WARN)
315321
@Message(
316322
value = """
@@ -504,22 +510,34 @@ void unableToLocateStaticMetamodelField(
504510
void collectionFoundUninitialized(String is, String was);
505511

506512
@LogMessage(level = TRACE)
507-
@Message( id = 6049, value = "Starting serialization of [%s] EntityEntry entries" )
513+
@Message( id = 6049, value = "Created collection wrapper for: %s" )
514+
void createdCollectionWrapper(String s);
515+
516+
@LogMessage(level = TRACE)
517+
@Message( id = 6051, value = "Starting serialization of [%s] EntityEntry entries" )
508518
void startingEntityEntrySerialization(int count);
509519

510520
@LogMessage(level = TRACE)
511-
@Message( id = 6050, value = "Starting deserialization of [%s] EntityEntry entries" )
521+
@Message( id = 6052, value = "Starting deserialization of [%s] EntityEntry entries" )
512522
void startingEntityEntryDeserialization(int count);
513523

514524
@LogMessage(level = ERROR)
515-
@Message( id = 6051, value = "Enable to deserialize [%s]" )
525+
@Message( id = 6053, value = "Unable to deserialize [%s]" )
516526
void unableToDeserialize(String entityEntryClassName);
517527

518528
@LogMessage(level = TRACE)
519529
@Message( id = 6061, value = "Extracted generated values for entity %s - %s" )
520-
void extractedGeneratedValues(String s, String string);
530+
void extractedGeneratedValues(String info, String results);
521531

522532
@LogMessage(level = WARN)
523533
@Message( id = 6062, value = "Could not resolve type name [%s] as Java type" )
524534
void couldNotResolveTypeName(String typeName, @Cause ClassLoadingException exception);
535+
536+
@LogMessage(level = DEBUG)
537+
@Message( id = 6063, value = "Problem releasing GenerationTarget [%s]" )
538+
void problemReleasingGenerationTarget(GenerationTarget target, @Cause Exception e);
539+
540+
@LogMessage(level = WARN)
541+
@Message( id = 6064, value = "Unable to close temp session" )
542+
void unableToCLoseTempSession();
525543
}

hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ protected void permissiveInitialization() {
236236
session.close();
237237
}
238238
catch (Exception e) {
239-
CORE_LOGGER.warn( "Unable to close temporary session used to load lazy proxy associated to no session" );
239+
CORE_LOGGER.unableToCLoseTempSession();
240240
}
241241
}
242242
}
243243
catch (Exception e) {
244-
CORE_LOGGER.error( "Initialization failure [" + entityName + "#" + id + "]", e );
245-
throw new LazyInitializationException( e.getMessage() );
244+
throw new LazyInitializationException( "Could not initialize proxy ["
245+
+ entityName + "#" + id + "]: " + e.getMessage() );
246246
}
247247
}
248248
else if ( session.isOpenOrWaitingForAutoClose() && session.isConnected() ) {

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void doCreation(
133133
target.release();
134134
}
135135
catch (Exception e) {
136-
CORE_LOGGER.debugf( "Problem releasing GenerationTarget [%s]: %s", target, e.getMessage() );
136+
CORE_LOGGER.problemReleasingGenerationTarget( target, e );
137137
}
138138
}
139139
}

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public void perform(ServiceRegistry serviceRegistry) {
629629
// implicitly we do not "halt on error", but we do want to
630630
// report the problem
631631
CORE_LOGGER.unsuccessfulSchemaManagementCommand( command );
632-
CORE_LOGGER.debugf( e, "Error performing delayed DROP command [%s]", command );
632+
CORE_LOGGER.unsuccessfulDelayedDropCommand( e );
633633
}
634634
}
635635
}

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaPopulatorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void doPopulation(Dialect dialect, ExecutionOptions options, GenerationTa
7171
target.release();
7272
}
7373
catch (Exception e) {
74-
CORE_LOGGER.debugf( "Problem releasing GenerationTarget [%s] : %s", target, e.getMessage() );
74+
CORE_LOGGER.problemReleasingGenerationTarget( target, e );
7575
}
7676
}
7777
}

hibernate-core/src/main/java/org/hibernate/type/CollectionType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,8 @@ else if ( overridingEager != null ? overridingEager : !persister.isLazy() ) {
822822
persistenceContext.addCollectionHolder( collection );
823823
}
824824
if ( CORE_LOGGER.isTraceEnabled() ) {
825-
CORE_LOGGER.trace( "Created collection wrapper: "
826-
+ collectionInfoString( persister, collection, key, session ) );
825+
CORE_LOGGER.createdCollectionWrapper(
826+
collectionInfoString( persister, collection, key, session ) );
827827
}
828828
return collection;
829829
}

0 commit comments

Comments
 (0)