Skip to content

Commit 76d6228

Browse files
committed
clean up some uses of BOOT_LOGGER
1 parent 6cfdc64 commit 76d6228

File tree

8 files changed

+36
-37
lines changed

8 files changed

+36
-37
lines changed

hibernate-core/src/main/java/org/hibernate/boot/BootLogging.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public interface BootLogging extends BasicLogger {
4545
@Message(id = 160101, value = "Duplicate generator name: '%s'")
4646
void duplicateGeneratorName(String name);
4747

48-
4948
@LogMessage(level = DEBUG)
5049
@Message(id = 160111, value = "Package not found or no package-info.java: %s")
5150
void packageNotFound(String packageName);
@@ -84,7 +83,6 @@ public interface BootLogging extends BasicLogger {
8483
@ManyToOne and @OneToOne associations mapped with @NotFound are forced to EAGER fetching""")
8584
void ignoreNotFoundWithFetchTypeLazy(String entity, String association);
8685

87-
// --- New typed TRACE/DEBUG messages for boot internals ---
8886
@LogMessage(level = TRACE)
8987
@Message(id = 160140, value = "Binding formula: %s")
9088
void bindingFormula(String formula);
@@ -449,4 +447,12 @@ public interface BootLogging extends BasicLogger {
449447
@LogMessage(level = DEBUG)
450448
@Message(id = 160244, value = "Skipping HBM processing of entity hierarchy [%s], as at least one entity [%s] has been processed")
451449
void skippingHbmProcessingOfEntityHierarchy(String rootEntityName, String processedEntity);
450+
451+
@LogMessage(level = WARN)
452+
@Message(id = 160245, value = "Association '%s' is 'mappedBy' another entity and should not specify a '@MapKeyColumn' (use '@MapKey' instead)")
453+
void mappedByShouldNotSpecifyMapKeyColumn(String associationPath);
454+
455+
@LogMessage(level = WARN)
456+
@Message(id = 160246, value = "Association '%s' is 'mappedBy' another entity and should not specify an '@OrderColumn' (use '@OrderBy' instead)")
457+
void mappedByShouldNotSpecifyOrderColumn(String associationPath);
452458
}

hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ public MetadataSources(ServiceRegistry serviceRegistry, XmlMappingBinderAccess x
105105
// service registry really should be either BootstrapServiceRegistry or StandardServiceRegistry type...
106106
if ( !isExpectedServiceRegistryType( serviceRegistry ) ) {
107107
if ( BOOT_LOGGER.isDebugEnabled() ) {
108-
BOOT_LOGGER.unexpectedServiceRegistryType(
109-
serviceRegistry.getClass().getName()
110-
);
108+
BOOT_LOGGER.unexpectedServiceRegistryType( serviceRegistry.getClass().getName() );
111109
}
112110
}
113111
this.serviceRegistry = serviceRegistry;

hibernate-core/src/main/java/org/hibernate/boot/archive/internal/ArchiveHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import org.hibernate.boot.archive.spi.ArchiveException;
1616

17+
import static org.hibernate.boot.BootLogging.BOOT_LOGGER;
18+
1719

1820
/**
1921
* Helper for dealing with archives
@@ -89,7 +91,7 @@ else if ( "zip".equals( protocol )
8991
"Unable to determine JAR Url from " + url + ". Cause: " + e.getMessage()
9092
);
9193
}
92-
org.hibernate.boot.BootLogging.BOOT_LOGGER.jarUrlFromUrlEntry( String.valueOf(url), String.valueOf(jarUrl) );
94+
BOOT_LOGGER.jarUrlFromUrlEntry( String.valueOf(url), String.valueOf(jarUrl) );
9395
return jarUrl;
9496
}
9597

hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,11 @@ public static LoadedConfig consume(JaxbCfgHibernateConfiguration jaxbCfg) {
100100
final String eventTypeName = listenerGroup.getType().value();
101101
final var eventType = EventType.resolveEventTypeByName( eventTypeName );
102102
for ( var listener : listenerGroup.getListener() ) {
103-
if ( listener.getType() != null ) {
104-
BOOT_LOGGER.listenerDefinedAlsoDefinedEventType(
105-
listener.getClazz()
106-
);
107-
}
108-
cfg.addEventListener( eventType, listener.getClazz() );
103+
final String listenerClassName = listener.getClazz();
104+
if ( listener.getType() != null ) {
105+
BOOT_LOGGER.listenerDefinedAlsoDefinedEventType( listenerClassName );
106+
}
107+
cfg.addEventListener( eventType, listenerClassName );
109108
}
110109
}
111110
}

hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void injectJpaTempClassLoader(ClassLoader classLoader) {
318318

319319
void injectScanOptions(ScanOptions scanOptions) {
320320
if ( scanOptions != this.scanOptions ) {
321-
BOOT_LOGGER.injectingScanOptions(scanOptions, this.scanOptions);
321+
BOOT_LOGGER.injectingScanOptions( scanOptions, this.scanOptions );
322322
}
323323
this.scanOptions = scanOptions;
324324
}
@@ -332,7 +332,7 @@ void injectScanEnvironment(ScanEnvironment scanEnvironment) {
332332

333333
void injectScanner(Scanner scanner) {
334334
if ( scanner != this.scannerSetting ) {
335-
BOOT_LOGGER.injectingScanner( scanner, scannerSetting );
335+
BOOT_LOGGER.injectingScanner( scanner, this.scannerSetting );
336336
}
337337
this.scannerSetting = scanner;
338338
}

hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ public AnnotatedColumn() {
235235

236236
public void bind() {
237237
if ( isNotEmpty( formulaString ) ) {
238-
if ( BOOT_LOGGER.isTraceEnabled() ) {
239-
BOOT_LOGGER.bindingFormula( formulaString );
240-
}
238+
BOOT_LOGGER.bindingFormula( formulaString );
241239
formula = new Formula();
242240
formula.setFormula( formulaString );
243241
}
@@ -269,7 +267,7 @@ public void bind() {
269267
if ( generatedAs != null ) {
270268
mappingColumn.setGeneratedAs( generatedAs );
271269
}
272-
if ( BOOT_LOGGER.isDebugEnabled() && logicalColumnName != null ) {
270+
if ( logicalColumnName != null ) {
273271
BOOT_LOGGER.bindingColumn( logicalColumnName );
274272
}
275273
}
@@ -770,7 +768,7 @@ private static jakarta.persistence.Column[] overrideColumns(
770768
+ " columns (every column must have exactly one '@AttributeOverride')" );
771769
}
772770
if ( BOOT_LOGGER.isTraceEnabled() ) {
773-
BOOT_LOGGER.columnMappingOverridden( inferredData.getPropertyName() );
771+
BOOT_LOGGER.columnMappingOverridden( inferredData.getPropertyName() );
774772
}
775773
return isEmpty( overriddenCols ) ? null : overriddenCols;
776774
}
@@ -930,7 +928,7 @@ void applyColumnDefault(PropertyData inferredData, int length) {
930928
}
931929
}
932930
else {
933-
BOOT_LOGGER.couldNotPerformColumnDefaultLookup();
931+
BOOT_LOGGER.couldNotPerformColumnDefaultLookup();
934932
}
935933
}
936934

@@ -951,7 +949,7 @@ void applyGeneratedAs(PropertyData inferredData, int length) {
951949
}
952950
}
953951
else {
954-
BOOT_LOGGER.couldNotPerformGeneratedColumnLookup();
952+
BOOT_LOGGER.couldNotPerformGeneratedColumnLookup();
955953
}
956954
}
957955

@@ -994,9 +992,9 @@ void applyCheckConstraint(PropertyData inferredData, int length) {
994992
}
995993
}
996994
else {
997-
BOOT_LOGGER.couldNotPerformCheckLookup();
995+
BOOT_LOGGER.couldNotPerformCheckLookup();
998996
}
999-
}
997+
}
1000998

1001999
//must only be called after all setters are defined and before binding
10021000
private void extractDataFromPropertyData(

hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,9 +1062,7 @@ private void bind() {
10621062
}
10631063
collection = createCollection( propertyHolder.getPersistentClass() );
10641064
final String role = qualify( propertyHolder.getPath(), propertyName );
1065-
if ( BOOT_LOGGER.isTraceEnabled() ) {
1066-
BOOT_LOGGER.bindingCollectionRole( role );
1067-
}
1065+
BOOT_LOGGER.bindingCollectionRole( role );
10681066
collection.setRole( role );
10691067
collection.setMappedByProperty( mappedBy );
10701068

@@ -1145,16 +1143,14 @@ private void detectMappedByProblem(boolean isMappedBy) {
11451143
}
11461144
if ( oneToMany ) {
11471145
if ( property.hasDirectAnnotationUsage( MapKeyColumn.class ) ) {
1148-
BOOT_LOGGER.warn( "Association '"
1149-
+ qualify( propertyHolder.getPath(), propertyName )
1150-
+ "' is 'mappedBy' another entity and should not specify a '@MapKeyColumn'"
1151-
+ " (use '@MapKey' instead)" );
1146+
BOOT_LOGGER.mappedByShouldNotSpecifyMapKeyColumn(
1147+
qualify( propertyHolder.getPath(), propertyName )
1148+
);
11521149
}
11531150
if ( property.hasDirectAnnotationUsage( OrderColumn.class ) ) {
1154-
BOOT_LOGGER.warn( "Association '"
1155-
+ qualify( propertyHolder.getPath(), propertyName )
1156-
+ "' is 'mappedBy' another entity and should not specify an '@OrderColumn'"
1157-
+ " (use '@OrderBy' instead)" );
1151+
BOOT_LOGGER.mappedByShouldNotSpecifyOrderColumn(
1152+
qualify( propertyHolder.getPath(), propertyName )
1153+
);
11581154
}
11591155
}
11601156
else {

hibernate-core/src/main/java/org/hibernate/boot/model/relational/Namespace.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ public void registerTable(Identifier logicalName, Table table) {
9595
final Table previous = tables.put( logicalName, table );
9696
if ( previous != null ) {
9797
BOOT_LOGGER.replacingTableRegistration(
98-
String.valueOf(logicalName),
99-
String.valueOf(previous),
100-
String.valueOf(table)
98+
String.valueOf( logicalName ),
99+
String.valueOf( previous ),
100+
String.valueOf( table )
101101
);
102102
}
103103
}

0 commit comments

Comments
 (0)