From 263893c4654a5fadacdeebc98ef980a0ed95a528 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sun, 14 Sep 2025 16:37:44 +0200 Subject: [PATCH] migrate calls to BOOT_LOGGER --- .../java/org/hibernate/boot/BootLogging.java | 323 ++++++++++++++++- .../org/hibernate/boot/MetadataSources.java | 8 +- .../InFlightMetadataCollectorImpl.java | 180 +++++----- .../boot/internal/MetadataBuilderImpl.java | 7 +- .../jaxb/internal/CacheableFileXmlSource.java | 28 +- .../boot/model/internal/AnnotatedColumn.java | 24 +- .../boot/model/internal/AnnotationBinder.java | 17 +- .../boot/model/internal/CollectionBinder.java | 36 +- .../internal/CollectionPropertyHolder.java | 4 +- .../model/internal/CollectionSecondPass.java | 10 +- .../boot/model/internal/EmbeddableBinder.java | 6 +- .../boot/model/internal/EntityBinder.java | 16 +- .../boot/model/internal/FilterDefBinder.java | 6 +- .../boot/model/internal/GeneratorBinder.java | 15 +- .../model/internal/GeneratorParameters.java | 4 +- .../boot/model/internal/QueryBinder.java | 32 +- .../internal/ResultSetMappingSecondPass.java | 2 +- .../boot/model/internal/ToOneBinder.java | 4 +- .../internal/ManagedResourcesImpl.java | 14 +- .../boot/model/relational/Namespace.java | 14 +- ...AnnotationMetadataSourceProcessorImpl.java | 117 +++--- .../source/internal/hbm/ModelBinder.java | 333 +++++++++--------- .../internal/GlobalRegistrationsImpl.java | 4 +- .../internal/ClassLoaderServiceImpl.java | 14 +- .../hibernate/internal/CoreMessageLogger.java | 57 --- ...ulaManyToOneNotIgnoreLazyFetchingTest.java | 6 +- ...mulaOneToOneNotIgnoreLazyFetchingTest.java | 6 +- 27 files changed, 751 insertions(+), 536 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/BootLogging.java b/hibernate-core/src/main/java/org/hibernate/boot/BootLogging.java index 8dc566cdedc4..aa1f117f3c34 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/BootLogging.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/BootLogging.java @@ -5,10 +5,26 @@ package org.hibernate.boot; import org.hibernate.Internal; +import org.hibernate.boot.model.relational.Namespace; import org.hibernate.internal.log.SubSystemLogging; +import java.io.File; +import java.io.FileNotFoundException; +import java.lang.invoke.MethodHandles; + +import org.hibernate.type.SerializationException; +import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; +import org.jboss.logging.annotations.Cause; +import org.jboss.logging.annotations.LogMessage; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageLogger; +import org.jboss.logging.annotations.ValidIdRange; +import static org.jboss.logging.Logger.Level.DEBUG; +import static org.jboss.logging.Logger.Level.TRACE; +import static org.jboss.logging.Logger.Level.WARN; +import static org.jboss.logging.Logger.Level.INFO; /** * Logging related to Hibernate bootstrapping @@ -17,8 +33,311 @@ name = BootLogging.NAME, description = "Logging related to bootstrapping of a SessionFactory / EntityManagerFactory" ) +@MessageLogger(projectCode = "HHH") +@ValidIdRange(min = 160101, max = 160200) @Internal -public interface BootLogging { +public interface BootLogging extends BasicLogger { String NAME = SubSystemLogging.BASE + ".boot"; - Logger BOOT_LOGGER = Logger.getLogger( NAME ); + BootLogging BOOT_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), BootLogging.class, NAME ); + + @LogMessage(level = WARN) + @Message(id = 160101, value = "Duplicate generator name %s") + void duplicateGeneratorName(String name); + + @LogMessage(level = INFO) + @Message(id = 160102, value = "Reading mappings from file: %s") + void readingMappingsFromFile(String path); + + @LogMessage(level = INFO) + @Message(id = 160103, value = "Reading mappings from cache file: %s") + void readingCachedMappings(File cachedFile); + + @LogMessage(level = WARN) + @Message(id = 160104, value = "Could not deserialize cache file [%s]: %s") + void unableToDeserializeCache(String path, SerializationException error); + + @LogMessage(level = WARN) + @Message(id = 160105, value = "I/O reported error writing cached file: [%s]: %s") + void unableToWriteCachedFile(String path, String message); + + @LogMessage(level = WARN) + @Message(id = 160106, value = "Could not update cached file timestamp: [%s]") + @SuppressWarnings("unused") + void unableToUpdateCachedFileTimestamp(String path); + + @LogMessage(level = WARN) + @Message(id = 160107, value = "I/O reported cached file could not be found: [%s]: %s") + void cachedFileNotFound(String path, FileNotFoundException error); + + @LogMessage(level = INFO) + @Message(id = 160108, value = "Omitting cached file [%s] as the mapping file is newer") + void cachedFileObsolete(File cachedFile); + + @LogMessage(level = DEBUG) + @Message(id = 160111, value = "Package not found or no package-info.java: %s") + void packageNotFound(String packageName); + + @LogMessage(level = WARN) + @Message(id = 160112, value = "LinkageError while attempting to load package: %s") + void linkageError(String packageName, @Cause LinkageError e); + + @LogMessage(level = TRACE) + @Message(id = 160121, value = "Trying via [new URL(\"%s\")]") + void tryingURL(String name); + + @LogMessage(level = TRACE) + @Message(id = 160122, value = "Trying via [ClassLoader.getResourceAsStream(\"%s\")]") + void tryingClassLoader(String name); + + @LogMessage(level = WARN) + @Message(id = 160130, value = "Ignoring unique constraints specified on table generator [%s]") + void ignoringTableGeneratorConstraints(String name); + + @LogMessage(level = WARN) + @Message( + id = 160131, + value = """ + @Convert annotation applied to Map attribute [%s] did not explicitly specify\ + 'attributeName="key" or 'attributeName="value"' as required by spec;\ + attempting to infer whether converter applies to key or value""" + ) + void nonCompliantMapConversion(String collectionRole); + + @LogMessage(level = WARN) + @Message( + id = 160133, + value = """ + '%1$s.%2$s' uses both @NotFound and FetchType.LAZY;\ + @ManyToOne and @OneToOne associations mapped with @NotFound are forced to EAGER fetching""") + void ignoreNotFoundWithFetchTypeLazy(String entity, String association); + + // --- New typed TRACE/DEBUG messages for boot internals --- + @LogMessage(level = TRACE) + @Message(id = 160140, value = "Binding formula: %s") + void bindingFormula(String formula); + + @LogMessage(level = TRACE) + @Message(id = 160141, value = "Binding column: %s") + void bindingColumn(String column); + + @LogMessage(level = TRACE) + @Message(id = 160142, value = "Column mapping overridden for property: %s") + void columnMappingOverridden(String propertyName); + + @LogMessage(level = TRACE) + @Message(id = 160143, value = "Could not perform @ColumnDefault lookup as 'PropertyData' did not give access to XProperty") + void couldNotPerformColumnDefaultLookup(); + + @LogMessage(level = TRACE) + @Message(id = 160144, value = "Could not perform @GeneratedColumn lookup as 'PropertyData' did not give access to XProperty") + void couldNotPerformGeneratedColumnLookup(); + + @LogMessage(level = TRACE) + @Message(id = 160145, value = "Could not perform @Check lookup as 'PropertyData' did not give access to XProperty") + void couldNotPerformCheckLookup(); + + @LogMessage(level = TRACE) + @Message(id = 160146, value = "Binding embeddable with path: %s") + void bindingEmbeddable(String path); + + @LogMessage(level = TRACE) + @Message(id = 160147, value = "Binding filter definition: %s") + void bindingFilterDefinition(String name); + + @LogMessage(level = TRACE) + @Message(id = 160148, value = "Second pass for collection: %s") + void secondPassForCollection(String role); + + @LogMessage(level = TRACE) + @Message(id = 160149, value = "Binding collection role: %s") + void bindingCollectionRole(String role); + + @LogMessage(level = TRACE) + @Message(id = 160150, value = "Binding one-to-many association through foreign key: %s") + void bindingOneToManyThroughForeignKey(String role); + + @LogMessage(level = TRACE) + @Message(id = 160151, value = "Binding one-to-many association through association table: %s") + void bindingOneToManyThroughAssociationTable(String role); + + @LogMessage(level = TRACE) + @Message(id = 160152, value = "Binding many-to-many association through association table: %s") + void bindingManyToManyThroughAssociationTable(String role); + + @LogMessage(level = TRACE) + @Message(id = 160153, value = "Binding many-to-any: %s") + void bindingManyToAny(String role); + + @LogMessage(level = TRACE) + @Message(id = 160154, value = "Binding element collection to collection table: %s") + void bindingElementCollectionToCollectionTable(String role); + + @LogMessage(level = TRACE) + @Message(id = 160155, value = "Import: %s -> %s") + void importEntry(String importName, String className); + + @LogMessage(level = TRACE) + @Message(id = 160156, value = "Processing association property references") + void processingAssociationPropertyReferences(); + + @LogMessage(level = TRACE) + @Message(id = 160157, value = "Mapping class: %s -> %s") + void mappingClassToTable(String entityName, String tableName); + + @LogMessage(level = TRACE) + @Message(id = 160158, value = "Mapping joined-subclass: %s -> %s") + void mappingJoinedSubclassToTable(String entityName, String tableName); + + @LogMessage(level = TRACE) + @Message(id = 160159, value = "Mapping union-subclass: %s -> %s") + void mappingUnionSubclassToTable(String entityName, String tableName); + + @LogMessage(level = TRACE) + @Message(id = 160160, value = "Mapped property: %s -> [%s]") + void mappedProperty(String propertyName, String columns); + + @LogMessage(level = TRACE) + @Message(id = 160161, value = "Binding dynamic component [%s]") + void bindingDynamicComponent(String role); + + @LogMessage(level = TRACE) + @Message(id = 160162, value = "Binding virtual component [%s] to owner class [%s]") + void bindingVirtualComponentToOwner(String role, String ownerClassName); + + @LogMessage(level = TRACE) + @Message(id = 160163, value = "Binding virtual component [%s] as dynamic") + void bindingVirtualComponentAsDynamic(String role); + + @LogMessage(level = TRACE) + @Message(id = 160164, value = "Binding component [%s]") + void bindingComponent(String role); + + @LogMessage(level = TRACE) + @Message(id = 160165, value = "Attempting to determine component class by reflection %s") + void attemptingToDetermineComponentClassByReflection(String role); + + @LogMessage(level = TRACE) + @Message(id = 160166, value = "Mapped collection: %s") + void mappedCollection(String role); + + @LogMessage(level = TRACE) + @Message(id = 160167, value = "Mapping collection: %s -> %s") + void mappingCollectionToTable(String role, String tableName); + + @LogMessage(level = TRACE) + @Message(id = 160168, value = "Binding natural id UniqueKey for entity: %s") + void bindingNaturalIdUniqueKey(String entityName); + + @LogMessage(level = TRACE) + @Message(id = 160169, value = "Binding named query '%s' to [%s]") + void bindingNamedQuery(String queryName, String bindingTarget); + + @LogMessage(level = TRACE) + @Message(id = 160170, value = "Binding named native query '%s' to [%s]") + void bindingNamedNativeQuery(String queryName, String bindingTarget); + + @LogMessage(level = TRACE) + @Message(id = 160171, value = "Binding SQL result set mapping '%s' to [%s]") + void bindingSqlResultSetMapping(String name, String target); + + @LogMessage(level = TRACE) + @Message(id = 160172, value = "Bound named stored procedure query: %s => %s") + void boundStoredProcedureQuery(String name, String procedure); + + @LogMessage(level = TRACE) + @Message(id = 160173, value = "Adding global sequence generator with name: %s") + void addingGlobalSequenceGenerator(String name); + + @LogMessage(level = TRACE) + @Message(id = 160174, value = "Adding global table generator with name: %s") + void addingGlobalTableGenerator(String name); + + @LogMessage(level = TRACE) + @Message(id = 160175, value = "Binding entity with annotated class: %s") + void bindingEntityWithAnnotatedClass(String className); + + @LogMessage(level = DEBUG) + @Message(id = 160176, value = "Import name [%s] overrode previous [{%s}]") + void importOverrodePrevious(String importName, String previous); + + @LogMessage(level = TRACE) + @Message(id = 160177, value = "%s") + void mappedCollectionDetails(String details); + + @LogMessage(level = TRACE) + @Message(id = 160178, value = "Mapping entity secondary table: %s -> %s") + void mappingEntitySecondaryTableToTable(String entityName, String tableName); + + @LogMessage(level = TRACE) + @Message(id = 160179, value = "Writing cache file for: %s to: %s") + void writingCacheFile(String xmlPath, String serPath); + + @LogMessage(level = DEBUG) + @Message(id = 160180, value = "Unexpected ServiceRegistry type [%s] encountered during building of MetadataSources; may cause problems later attempting to construct MetadataBuilder") + void unexpectedServiceRegistryType(String registryType); + + @LogMessage(level = TRACE) + @Message(id = 160181, value = "Created database namespace [logicalName=%s, physicalName=%s]") + void createdDatabaseNamespace(Namespace.Name logicalName, Namespace.Name physicalName); + + @LogMessage(level = DEBUG) + @Message(id = 160182, value = "Could load component class [%s]") + void couldLoadComponentClass(String className, @Cause Throwable ex); + + @LogMessage(level = DEBUG) + @Message(id = 160183, value = "Unable to load explicit any-discriminator type name as Java Class - %s") + void unableToLoadExplicitAnyDiscriminatorType(String typeName); + + @LogMessage(level = DEBUG) + @Message(id = 160184, value = "Ignoring exception thrown when trying to build IdentifierGenerator as part of Metadata building") + void ignoringExceptionBuildingIdentifierGenerator(@Cause Throwable ex); + + @LogMessage(level = TRACE) + @Message(id = 160185, value = "Binding component [%s] to explicitly specified class [%s]") + void bindingComponentToExplicitClass(String role, String className); + + @LogMessage(level = DEBUG) + @Message(id = 160186, value = "Unable to determine component class name via reflection, and explicit class name not given; role=[%s]") + void unableToDetermineComponentClassByReflection(String role); + + @LogMessage(level = DEBUG) + @Message(id = 160187, value = "Replacing Table registration(%s) : %s -> %s") + void replacingTableRegistration(String logicalName, String previous, String table); + + @LogMessage(level = DEBUG) + @Message(id = 160188, value = "Ignoring %s XML mappings due to '%s'") + void ignoringXmlMappings(int count, String setting); + + @LogMessage(level = WARN) + @Message(id = 160189, value = "Duplicate fetch profile name '%s'") + void duplicatedFetchProfile(String name); + + // EntityBinder discriminator handling + @LogMessage(level = TRACE) + @Message(id = 160190, value = "Ignoring explicit @DiscriminatorColumn annotation on: %s") + void ignoringExplicitDiscriminatorForJoined(String className); + + @LogMessage(level = TRACE) + @Message(id = 160191, value = "Inferring implicit @DiscriminatorColumn using defaults for: %s") + void inferringImplicitDiscriminatorForJoined(String className); + + // GeneratorBinder additions + @LogMessage(level = TRACE) + @Message(id = 160192, value = "Added generator with name: %s, strategy: %s") + void addedGenerator(String name, String strategy); + + @LogMessage(level = TRACE) + @Message(id = 160193, value = "Added sequence generator with name: %s") + void addedSequenceGenerator(String name); + + @LogMessage(level = TRACE) + @Message(id = 160194, value = "Added table generator with name: %s") + void addedTableGenerator(String name); + + @LogMessage(level = DEBUG) + @Message(id = 160195, + value = """ + ServiceRegistry passed to MetadataBuilder was a BootstrapServiceRegistry; \ + this likely won't end well if attempt is made to build SessionFactory""") + void badServiceRegistry(); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java b/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java index 6d5e29387b1e..ef46107b6dda 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java @@ -41,7 +41,7 @@ import static java.util.Collections.addAll; import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.collections.CollectionHelper.arrayList; /** @@ -104,10 +104,8 @@ public MetadataSources(ServiceRegistry serviceRegistry) { public MetadataSources(ServiceRegistry serviceRegistry, XmlMappingBinderAccess xmlMappingBinderAccess) { // service registry really should be either BootstrapServiceRegistry or StandardServiceRegistry type... if ( !isExpectedServiceRegistryType( serviceRegistry ) ) { - if ( CORE_LOGGER.isDebugEnabled() ) { - CORE_LOGGER.debugf( - "Unexpected ServiceRegistry type [%s] encountered during building of MetadataSources; may cause " + - "problems later attempting to construct MetadataBuilder", + if ( BOOT_LOGGER.isDebugEnabled() ) { + BOOT_LOGGER.unexpectedServiceRegistryType( serviceRegistry.getClass().getName() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java index e4b9aba67963..7388aa0a2475 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java @@ -63,7 +63,7 @@ import org.hibernate.boot.spi.NaturalIdUniqueKeyBinder; import org.hibernate.boot.spi.PropertyData; import org.hibernate.boot.spi.SecondPass; -import org.hibernate.cfg.AvailableSettings; +import org.hibernate.cfg.JpaComplianceSettings; import org.hibernate.dialect.Dialect; import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.config.spi.StandardConverters; @@ -117,7 +117,7 @@ import static org.hibernate.boot.model.relational.internal.SqlStringGenerationContextImpl.fromExplicit; import static org.hibernate.cfg.MappingSettings.DEFAULT_CATALOG; import static org.hibernate.cfg.MappingSettings.DEFAULT_SCHEMA; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty; import static org.hibernate.internal.util.collections.CollectionHelper.mapOfSize; @@ -635,9 +635,9 @@ public void addFetchProfile(FetchProfile profile) { if ( profile == null || profile.getName() == null ) { throw new IllegalArgumentException( "Fetch profile object or name is null: " + profile ); } - final FetchProfile old = fetchProfileMap.put( profile.getName(), profile ); + final var old = fetchProfileMap.put( profile.getName(), profile ); if ( old != null ) { - CORE_LOGGER.warn( "Duplicated fetch profile with same name [" + profile.getName() + "] found." ); + BOOT_LOGGER.duplicatedFetchProfile( profile.getName() ); } } @@ -668,17 +668,17 @@ public void addIdentifierGenerator(IdentifierGeneratorDefinition generator) { throw new IllegalArgumentException( "ID generator object or name is null." ); } else if ( !generator.getName().isEmpty() - && !defaultIdentifierGeneratorNames.contains( generator.getName() ) ) { - final IdentifierGeneratorDefinition old = - idGeneratorDefinitionMap.put( generator.getName(), generator ); + && !defaultIdentifierGeneratorNames.contains( generator.getName() ) ) { + final var old = idGeneratorDefinitionMap.put( generator.getName(), generator ); if ( old != null && !old.equals( generator ) ) { if ( bootstrapContext.getJpaCompliance().isGlobalGeneratorScopeEnabled() ) { - throw new IllegalArgumentException( "Duplicate generator name " + old.getName() - + "; you will likely want to set the property " - + AvailableSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE + " to false " ); + throw new IllegalArgumentException( "Duplicate generator name '" + old.getName() + + "'; you will likely want to set the property '" + + JpaComplianceSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE + + "' to false " ); } else { - CORE_LOGGER.duplicateGeneratorName( old.getName() ); + BOOT_LOGGER.duplicateGeneratorName( old.getName() ); } } } @@ -709,7 +709,7 @@ public Map getNamedEntityGraphs() { @Override public void addNamedEntityGraph(NamedEntityGraphDefinition definition) { final String name = definition.name(); - final NamedEntityGraphDefinition previous = namedEntityGraphMap.put( name, definition ); + final var previous = namedEntityGraphMap.put( name, definition ); if ( previous != null ) { throw new DuplicateMappingException( DuplicateMappingException.Type.NAMED_ENTITY_GRAPH, name ); } @@ -818,12 +818,13 @@ public void addNamedProcedureCallDefinition(NamedProcedureCallDefinition definit if ( definition == null ) { throw new IllegalArgumentException( "Named query definition is null" ); } - - final String name = definition.getRegistrationName(); - if ( !defaultNamedProcedureNames.contains( name ) ) { - final NamedProcedureCallDefinition previous = namedProcedureCallMap.put( name, definition ); - if ( previous != null ) { - throw new DuplicateMappingException( DuplicateMappingException.Type.PROCEDURE, name ); + else { + final String name = definition.getRegistrationName(); + if ( !defaultNamedProcedureNames.contains( name ) ) { + final NamedProcedureCallDefinition previous = namedProcedureCallMap.put( name, definition ); + if ( previous != null ) { + throw new DuplicateMappingException( DuplicateMappingException.Type.PROCEDURE, name ); + } } } } @@ -853,18 +854,19 @@ public void addResultSetMapping(NamedResultSetMappingDescriptor resultSetMapping if ( resultSetMappingDescriptor == null ) { throw new IllegalArgumentException( "Result-set mapping was null" ); } - - final String name = resultSetMappingDescriptor.getRegistrationName(); - if ( name == null ) { - throw new IllegalArgumentException( "Result-set mapping name is null: " + resultSetMappingDescriptor ); - } - else if ( !defaultSqlResultSetMappingNames.contains( name ) ) { - applyResultSetMapping( resultSetMappingDescriptor ); + else { + final String name = resultSetMappingDescriptor.getRegistrationName(); + if ( name == null ) { + throw new IllegalArgumentException( "Result-set mapping name is null: " + resultSetMappingDescriptor ); + } + else if ( !defaultSqlResultSetMappingNames.contains( name ) ) { + applyResultSetMapping( resultSetMappingDescriptor ); + } } } public void applyResultSetMapping(NamedResultSetMappingDescriptor resultSetMappingDescriptor) { - final NamedResultSetMappingDescriptor old = sqlResultSetMappingMap.put( + final var old = sqlResultSetMappingMap.put( resultSetMappingDescriptor.getRegistrationName(), resultSetMappingDescriptor ); @@ -900,10 +902,10 @@ public void addImport(String importName, String className) { if ( importName == null || className == null ) { throw new IllegalArgumentException( "Import name or entity name is null" ); } - CORE_LOGGER.tracev( "Import: {0} -> {1}", importName, className); + BOOT_LOGGER.importEntry( importName, className ); final String old = imports.put( importName, className); if ( old != null ) { - CORE_LOGGER.debugf( "Import name [%s] overrode previous [{%s}]", importName, old ); + BOOT_LOGGER.importOverrodePrevious( importName, old ); } } @@ -923,11 +925,9 @@ public Table addTable( getDatabase().toIdentifier( catalogName ), getDatabase().toIdentifier( schemaName ) ); - // annotation binding depends on the "table name" for @Subselect bindings // being set into the generated table (mainly to avoid later NPE), but for now we need to keep that :( final Identifier logicalName = name != null ? getDatabase().toIdentifier( name ) : null; - if ( subselectFragment != null ) { return new Table( buildingContext.getCurrentContributorName(), namespace, logicalName, subselectFragment, isAbstract ); @@ -940,13 +940,14 @@ public Table addTable( } return existing; } - - return namespace.createTable( - logicalName, - (physicalName) -> - new Table( buildingContext.getCurrentContributorName(), - namespace, physicalName, isAbstract ) - ); + else { + return namespace.createTable( + logicalName, + (physicalName) -> + new Table( buildingContext.getCurrentContributorName(), + namespace, physicalName, isAbstract ) + ); + } } } @@ -959,14 +960,12 @@ public Table addDenormalizedTable( String subselectFragment, Table includedTable, MetadataBuildingContext buildingContext) throws DuplicateMappingException { - final Database db = getDatabase(); + final var database = getDatabase(); final Namespace namespace = - db.locateNamespace( db.toIdentifier( catalogName ), db.toIdentifier( schemaName ) ); - + database.locateNamespace( database.toIdentifier( catalogName ), database.toIdentifier( schemaName ) ); // annotation binding depends on the "table name" for @Subselect bindings // being set into the generated table (mainly to avoid later NPE), but for now we need to keep that :( - final Identifier logicalName = name != null ? db.toIdentifier( name ) : null; - + final Identifier logicalName = name != null ? database.toIdentifier( name ) : null; if ( subselectFragment != null ) { return namespace.createDenormalizedTable( logicalName, @@ -1006,16 +1005,16 @@ public Table addDenormalizedTable( @Override public org.hibernate.type.Type getIdentifierType(String entityName) throws MappingException { - final PersistentClass pc = entityBindingMap.get( entityName ); - if ( pc == null ) { + final var persistentClass = entityBindingMap.get( entityName ); + if ( persistentClass == null ) { throw new MappingException( "persistent class not known: " + entityName ); } - return pc.getIdentifier().getType(); + return persistentClass.getIdentifier().getType(); } @Override public String getIdentifierPropertyName(String entityName) throws MappingException { - final PersistentClass persistentClass = entityBindingMap.get( entityName ); + final var persistentClass = entityBindingMap.get( entityName ); if ( persistentClass == null ) { throw new MappingException( "persistent class not known: " + entityName ); } @@ -1026,11 +1025,11 @@ public String getIdentifierPropertyName(String entityName) throws MappingExcepti @Override public org.hibernate.type.Type getReferencedPropertyType(String entityName, String propertyName) throws MappingException { - final PersistentClass persistentClass = entityBindingMap.get( entityName ); + final var persistentClass = entityBindingMap.get( entityName ); if ( persistentClass == null ) { throw new MappingException( "Persistent class not known: " + entityName ); } - final Property prop = persistentClass.getReferencedProperty( propertyName ); + final var prop = persistentClass.getReferencedProperty( propertyName ); if ( prop == null ) { throw new MappingException( "Property not known: " + entityName + '.' + propertyName ); } @@ -1250,13 +1249,13 @@ public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabase @Override public AnnotatedClassType getClassType(ClassDetails clazz) { - final AnnotatedClassType type = annotatedClassTypeMap.get( clazz.getName() ); + final var type = annotatedClassTypeMap.get( clazz.getName() ); return type == null ? addClassType( clazz ) : type; } @Override public AnnotatedClassType addClassType(ClassDetails clazz) { - final AnnotatedClassType type = getAnnotatedClassType(clazz); + final var type = getAnnotatedClassType( clazz ); annotatedClassTypeMap.put( clazz.getName(), type ); return type; } @@ -1380,14 +1379,14 @@ public DelayedPropertyReferenceHandlerAnnotationImpl(String referencedClass, Str @Override public void process(InFlightMetadataCollector metadataCollector) { - final PersistentClass clazz = metadataCollector.getEntityBinding( referencedClass ); - if ( clazz == null ) { + final var persistentClass = metadataCollector.getEntityBinding( referencedClass ); + if ( persistentClass == null ) { throw new MappingException( "property-ref to unmapped class: " + referencedClass ); } - final Property prop = clazz.getReferencedProperty( propertyName ); + final var property = persistentClass.getReferencedProperty( propertyName ); if ( unique ) { - ( (SimpleValue) prop.getValue() ).setAlternateUniqueKey( true ); + ( (SimpleValue) property.getValue() ).setAlternateUniqueKey( true ); } } } @@ -1427,14 +1426,12 @@ public EntityTableXref addEntityTableXref( Identifier primaryTableLogicalName, Table primaryTable, EntityTableXref superEntityTableXref) { - final EntityTableXrefImpl entry = new EntityTableXrefImpl( + final var entry = new EntityTableXrefImpl( primaryTableLogicalName, primaryTable, (EntityTableXrefImpl) superEntityTableXref ); - entityTableXrefMap.put( entityName, entry ); - return entry; } @@ -1474,7 +1471,6 @@ public void addSecondaryTable( ); } - if ( secondaryTableJoinMap == null ) { //secondaryTableJoinMap = new HashMap(); //secondaryTableJoinMap.put( logicalName, secondaryTableJoin ); @@ -1484,7 +1480,6 @@ public void addSecondaryTable( else { //final Join existing = secondaryTableJoinMap.put( logicalName, secondaryTableJoin ); final Join existing = secondaryTableJoinMap.put( logicalName.getCanonicalName(), secondaryTableJoin ); - if ( existing != null ) { throw new org.hibernate.boot.MappingException( String.format( @@ -1808,22 +1803,22 @@ private void processFkSecondPassesInOrder() { // While doing so build a map of class names to FkSecondPass instances depending on this class. final Map> isADependencyOf = new HashMap<>(); final List endOfQueueFkSecondPasses = new ArrayList<>( fkSecondPassList.size() ); - for ( FkSecondPass sp : fkSecondPassList ) { - if ( sp.isInPrimaryKey() ) { - final String referencedEntityName = sp.getReferencedEntityName(); - final PersistentClass classMapping = getEntityBinding( referencedEntityName ); + for ( var fkSecondPass : fkSecondPassList ) { + if ( fkSecondPass.isInPrimaryKey() ) { + final String referencedEntityName = fkSecondPass.getReferencedEntityName(); + final var classMapping = getEntityBinding( referencedEntityName ); if ( classMapping == null ) { - throw new HibernateException("Primary key referenced an unknown entity: " + throw new HibernateException( "Primary key referenced an unknown entity: " + referencedEntityName ); } final String dependentTable = classMapping.getTable().getQualifiedTableName().render(); if ( !isADependencyOf.containsKey( dependentTable ) ) { isADependencyOf.put( dependentTable, new HashSet<>() ); } - isADependencyOf.get( dependentTable ).add( sp ); + isADependencyOf.get( dependentTable ).add( fkSecondPass ); } else { - endOfQueueFkSecondPasses.add( sp ); + endOfQueueFkSecondPasses.add( fkSecondPass ); } } @@ -1866,13 +1861,13 @@ private void buildRecursiveOrderedFkSecondPasses( String currentTable) { final Set dependencies = isADependencyOf.get( currentTable ); if ( dependencies != null ) { - for ( FkSecondPass pass : dependencies ) { - final String dependentTable = pass.getValue().getTable().getQualifiedTableName().render(); + for ( var fkSecondPass : dependencies ) { + final String dependentTable = fkSecondPass.getValue().getTable().getQualifiedTableName().render(); if ( dependentTable.compareTo( startTable ) != 0 ) { buildRecursiveOrderedFkSecondPasses( orderedFkSecondPasses, isADependencyOf, startTable, dependentTable ); } - if ( !orderedFkSecondPasses.contains( pass ) ) { - orderedFkSecondPasses.add( 0, pass ); + if ( !orderedFkSecondPasses.contains( fkSecondPass ) ) { + orderedFkSecondPasses.add( 0, fkSecondPass ); } } } @@ -1880,12 +1875,10 @@ private void buildRecursiveOrderedFkSecondPasses( } private void processEndOfQueue(List endOfQueueFkSecondPasses) { - /* - * If a second pass raises a recoverableException, queue it for next round - * stop of no pass has to be processed or if the number of pass to processes - * does not diminish between two rounds. - * If some failing pass remain, raise the original exception - */ + // If a second pass raises a recoverableException, queue it for next round + // stop of no pass has to be processed or if the number of pass to processes + // does not diminish between two rounds. + // If some failing pass remain, raise the original exception boolean stopProcess = false; RuntimeException originalException = null; while ( !stopProcess ) { @@ -1923,27 +1916,22 @@ private void secondPassCompileForeignKeys(MetadataBuildingContext buildingContex protected void secondPassCompileForeignKeys(Table table, Set done, MetadataBuildingContext buildingContext) throws MappingException { table.createForeignKeys( buildingContext ); - - final Dialect dialect = getDialect(); - for ( ForeignKey foreignKey : table.getForeignKeyCollection() ) { + final var dialect = getDialect(); + for ( var foreignKey : table.getForeignKeyCollection() ) { if ( !done.contains( foreignKey ) ) { done.add( foreignKey ); - final PersistentClass referencedClass = foreignKey.resolveReferencedClass(this); - + final var referencedClass = foreignKey.resolveReferencedClass(this); if ( referencedClass.isJoinedSubclass() ) { secondPassCompileForeignKeys( referencedClass.getSuperclass().getTable(), done, buildingContext); } - // the ForeignKeys created in the first pass did not have their referenced table initialized if ( foreignKey.getReferencedTable() == null ) { foreignKey.setReferencedTable( referencedClass.getTable() ); } - final Identifier nameIdentifier = getMetadataBuildingOptions().getImplicitNamingStrategy() .determineForeignKeyName( new ForeignKeyNameSource( foreignKey, table, buildingContext ) ); foreignKey.setName( nameIdentifier.render( dialect ) ); - foreignKey.alignColumns(); } } @@ -1951,12 +1939,10 @@ protected void secondPassCompileForeignKeys(Table table, Set done, M private void processPropertyReferences() { if ( delayedPropertyReferenceHandlers != null ) { - CORE_LOGGER.trace( "Processing association property references" ); - - for ( DelayedPropertyReferenceHandler delayedPropertyReferenceHandler : delayedPropertyReferenceHandlers ) { + BOOT_LOGGER.processingAssociationPropertyReferences(); + for ( var delayedPropertyReferenceHandler : delayedPropertyReferenceHandlers ) { delayedPropertyReferenceHandler.process( this ); } - delayedPropertyReferenceHandlers.clear(); } } @@ -1973,7 +1959,7 @@ public void registerNaturalIdUniqueKeyBinder(String entityName, NaturalIdUniqueK if ( naturalIdUniqueKeyBinderMap == null ) { naturalIdUniqueKeyBinderMap = new HashMap<>(); } - final NaturalIdUniqueKeyBinder previous = naturalIdUniqueKeyBinderMap.put( entityName, ukBinder ); + final var previous = naturalIdUniqueKeyBinderMap.put( entityName, ukBinder ); if ( previous != null ) { throw new AssertionFailure( "Previous NaturalIdUniqueKeyBinder already registered for entity name : " + entityName ); } @@ -1981,7 +1967,7 @@ public void registerNaturalIdUniqueKeyBinder(String entityName, NaturalIdUniqueK private void processNaturalIdUniqueKeyBinders() { if ( naturalIdUniqueKeyBinderMap != null ) { - for ( NaturalIdUniqueKeyBinder naturalIdUniqueKeyBinder : naturalIdUniqueKeyBinderMap.values() ) { + for ( var naturalIdUniqueKeyBinder : naturalIdUniqueKeyBinderMap.values() ) { naturalIdUniqueKeyBinder.process(); } naturalIdUniqueKeyBinderMap.clear(); @@ -1990,9 +1976,9 @@ private void processNaturalIdUniqueKeyBinders() { private void processCachingOverrides() { if ( bootstrapContext.getCacheRegionDefinitions() != null ) { - for ( CacheRegionDefinition cacheRegionDefinition : bootstrapContext.getCacheRegionDefinitions() ) { + for ( var cacheRegionDefinition : bootstrapContext.getCacheRegionDefinitions() ) { if ( cacheRegionDefinition.regionType() == CacheRegionDefinition.CacheRegionType.ENTITY ) { - final PersistentClass entityBinding = getEntityBinding( cacheRegionDefinition.role() ); + final var entityBinding = getEntityBinding( cacheRegionDefinition.role() ); if ( entityBinding == null ) { throw new HibernateException( "Cache override referenced an unknown entity : " + cacheRegionDefinition.role() @@ -2009,7 +1995,7 @@ private void processCachingOverrides() { rootClass.setLazyPropertiesCacheable( cacheRegionDefinition.cacheLazy() ); } else if ( cacheRegionDefinition.regionType() == CacheRegionDefinition.CacheRegionType.COLLECTION ) { - final Collection collectionBinding = getCollectionBinding( cacheRegionDefinition.role() ); + final var collectionBinding = getCollectionBinding( cacheRegionDefinition.role() ); if ( collectionBinding == null ) { throw new HibernateException( "Cache override referenced an unknown collection role : " + cacheRegionDefinition.role() @@ -2069,9 +2055,9 @@ public MetadataImpl buildMetadataInstance(MetadataBuildingContext buildingContex private void processExportableProducers() { // for now we only handle id generators as ExportableProducers - final Dialect dialect = getDialect(); + final var dialect = getDialect(); - for ( PersistentClass entityBinding : entityBindingMap.values() ) { + for ( var entityBinding : entityBindingMap.values() ) { entityBinding.assignCheckConstraintsToTable( dialect, bootstrapContext.getTypeConfiguration() ); if ( entityBinding instanceof RootClass rootClass ) { handleIdentifierValueBinding( @@ -2083,7 +2069,7 @@ private void processExportableProducers() { } } - for ( Collection collection : collectionBindingMap.values() ) { + for ( var collection : collectionBindingMap.values() ) { if ( collection instanceof IdentifierCollection identifierCollection ) { handleIdentifierValueBinding( identifierCollection.getIdentifier(), @@ -2105,7 +2091,7 @@ private void handleIdentifierValueBinding( // by tools. We want to hold off requiring classes being present until we // try to build the SF. Here, just building the Metadata, it is "ok" for an // exception to occur, the same exception will happen later as we build the SF. - CORE_LOGGER.debug( "Ignoring exception thrown when trying to build IdentifierGenerator as part of Metadata building", e ); + BOOT_LOGGER.ignoringExceptionBuildingIdentifierGenerator( e ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java index 228ecee5bd96..26f030267935 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java @@ -90,7 +90,7 @@ import static org.hibernate.engine.config.spi.StandardConverters.BOOLEAN; import static org.hibernate.engine.config.spi.StandardConverters.STRING; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.NullnessHelper.coalesceSuppliedValues; import static org.hibernate.internal.util.StringHelper.nullIfEmpty; import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty; @@ -116,10 +116,7 @@ else if ( serviceRegistry instanceof StandardServiceRegistry standardServiceRegi return standardServiceRegistry; } else if ( serviceRegistry instanceof BootstrapServiceRegistry bootstrapServiceRegistry ) { - CORE_LOGGER.debug( - "ServiceRegistry passed to MetadataBuilder was a BootstrapServiceRegistry; this likely won't end well " + - "if attempt is made to build SessionFactory" - ); + BOOT_LOGGER.badServiceRegistry(); return new StandardServiceRegistryBuilder( bootstrapServiceRegistry ).build(); } else { diff --git a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java index 0af44e674777..f32e19277329 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java @@ -17,7 +17,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; /** * Support for creating a mapping {@linkplain Binding binding} from "cached" XML files. @@ -73,17 +73,17 @@ public static Binding fromCacheableFile return new Binding<>( readSerFile( serFile ), origin ); } catch ( SerializationException e ) { - CORE_LOGGER.unableToDeserializeCache( serFile.getName(), e ); + BOOT_LOGGER.unableToDeserializeCache( serFile.getName(), e ); } catch ( FileNotFoundException e ) { - CORE_LOGGER.cachedFileNotFound( serFile.getName(), e ); + BOOT_LOGGER.cachedFileNotFound( serFile.getName(), e ); } } else { - CORE_LOGGER.cachedFileObsolete( serFile ); + BOOT_LOGGER.cachedFileObsolete( serFile ); } - CORE_LOGGER.readingMappingsFromFile( xmlFile.getPath() ); + BOOT_LOGGER.readingMappingsFromFile( xmlFile.getPath() ); final Binding binding = FileXmlSource.fromFile( xmlFile, binder ); writeSerFile( binding.getRoot(), xmlFile, serFile ); @@ -124,7 +124,7 @@ public static File determineCachedFile(File xmlFile, File serDirectory) { } private static T readSerFile(File serFile) throws SerializationException, FileNotFoundException { - CORE_LOGGER.readingCachedMappings( serFile ); + BOOT_LOGGER.readingCachedMappings( serFile ); return SerializationHelper.deserialize( new FileInputStream( serFile ) ); } @@ -132,18 +132,18 @@ private static void writeSerFile( T jaxbModel, File xmlFile, File serFile) { - try ( FileOutputStream fos = new FileOutputStream( serFile ) ) { - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( "Writing cache file for: %s to: %s", xmlFile.getAbsolutePath(), serFile.getAbsolutePath() ); + try ( var fileOutputStream = new FileOutputStream( serFile ) ) { + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.writingCacheFile( xmlFile.getAbsolutePath(), serFile.getAbsolutePath() ); } - SerializationHelper.serialize( jaxbModel, fos ); - boolean success = serFile.setLastModified( System.currentTimeMillis() ); + SerializationHelper.serialize( jaxbModel, fileOutputStream ); + final boolean success = serFile.setLastModified( System.currentTimeMillis() ); if ( !success ) { - CORE_LOGGER.warn( "Could not update cacheable hbm.xml bin file timestamp" ); + BOOT_LOGGER.unableToUpdateCachedFileTimestamp( serFile.getAbsolutePath() ); } } catch ( Exception e ) { - CORE_LOGGER.unableToWriteCachedFile( serFile.getAbsolutePath(), e.getMessage() ); + BOOT_LOGGER.unableToWriteCachedFile( serFile.getAbsolutePath(), e.getMessage() ); } } @@ -152,7 +152,7 @@ public static void createSerFile(File xmlFile, MappingBinder binder) { } public static void createSerFile(File xmlFile, File outputFile, MappingBinder binder) { - final Binding binding = FileXmlSource.fromFile( xmlFile, binder ); + final var binding = FileXmlSource.fromFile( xmlFile, binder ); writeSerFile( binding.getRoot(), xmlFile, outputFile ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java index d861fd0661f0..5ff06ffcb345 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java @@ -39,7 +39,7 @@ import static org.hibernate.boot.model.internal.BinderHelper.getPath; import static org.hibernate.boot.model.internal.BinderHelper.getRelativePath; import static org.hibernate.boot.model.internal.DialectOverridesAnnotationHelper.getOverridableAnnotation; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.StringHelper.isBlank; import static org.hibernate.internal.util.StringHelper.isEmpty; import static org.hibernate.internal.util.StringHelper.isNotEmpty; @@ -235,8 +235,8 @@ public AnnotatedColumn() { public void bind() { if ( isNotEmpty( formulaString ) ) { - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Binding formula: " + formulaString ); +if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.bindingFormula( formulaString ); } formula = new Formula(); formula.setFormula( formulaString ); @@ -269,8 +269,8 @@ public void bind() { if ( generatedAs != null ) { mappingColumn.setGeneratedAs( generatedAs ); } - if ( CORE_LOGGER.isDebugEnabled() && logicalColumnName != null ) { - CORE_LOGGER.trace( "Binding column: " + logicalColumnName ); +if ( BOOT_LOGGER.isDebugEnabled() && logicalColumnName != null ) { + BOOT_LOGGER.bindingColumn( logicalColumnName ); } } } @@ -769,8 +769,8 @@ private static jakarta.persistence.Column[] overrideColumns( + " '@AttributeOverride's but the overridden property has " + overriddenCols.length + " columns (every column must have exactly one '@AttributeOverride')" ); } - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Column mapping overridden for property: " + inferredData.getPropertyName() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.columnMappingOverridden( inferredData.getPropertyName() ); } return isEmpty( overriddenCols ) ? null : overriddenCols; } @@ -930,7 +930,7 @@ void applyColumnDefault(PropertyData inferredData, int length) { } } else { - CORE_LOGGER.trace("Could not perform @ColumnDefault lookup as 'PropertyData' did not give access to XProperty"); +BOOT_LOGGER.couldNotPerformColumnDefaultLookup(); } } @@ -951,9 +951,9 @@ void applyGeneratedAs(PropertyData inferredData, int length) { } } else { - CORE_LOGGER.trace("Could not perform @GeneratedColumn lookup as 'PropertyData' did not give access to XProperty"); +BOOT_LOGGER.couldNotPerformGeneratedColumnLookup(); } - } +} private void applyColumnCheckConstraint(jakarta.persistence.Column column) { applyCheckConstraints( column.check() ); @@ -994,9 +994,9 @@ void applyCheckConstraint(PropertyData inferredData, int length) { } } else { - CORE_LOGGER.trace("Could not perform @Check lookup as 'PropertyData' did not give access to XProperty"); +BOOT_LOGGER.couldNotPerformCheckLookup(); } - } +} //must only be called after all setters are defined and before binding private void extractDataFromPropertyData( diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java index 15227021ca56..593d1a20fc1c 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java @@ -48,7 +48,7 @@ import static org.hibernate.boot.model.internal.GeneratorParameters.interpretTableGenerator; import static org.hibernate.boot.model.internal.InheritanceState.getInheritanceStateOfSuperEntity; import static org.hibernate.boot.model.internal.InheritanceState.getSuperclassInheritanceState; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.StringHelper.unqualify; import static org.hibernate.mapping.MetadataSource.ANNOTATIONS; @@ -76,9 +76,9 @@ public static void bindDefaults(MetadataBuildingContext context) { globalRegistrations.getSequenceGeneratorRegistrations().forEach( (name, generatorRegistration) -> { final var definitionBuilder = new IdentifierGeneratorDefinition.Builder(); interpretSequenceGenerator( generatorRegistration.configuration(), definitionBuilder ); - final IdentifierGeneratorDefinition idGenDef = definitionBuilder.build(); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Adding global sequence generator with name: " + name ); + final var idGenDef = definitionBuilder.build(); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.addingGlobalSequenceGenerator( name ); } metadataCollector.addDefaultIdentifierGenerator( idGenDef ); } ); @@ -86,9 +86,9 @@ public static void bindDefaults(MetadataBuildingContext context) { globalRegistrations.getTableGeneratorRegistrations().forEach( (name, generatorRegistration) -> { final var definitionBuilder = new IdentifierGeneratorDefinition.Builder(); interpretTableGenerator( generatorRegistration.configuration(), definitionBuilder ); - final IdentifierGeneratorDefinition idGenDef = definitionBuilder.build(); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Adding global table generator with name: " + name ); + final var idGenDef = definitionBuilder.build(); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.addingGlobalTableGenerator( name ); } metadataCollector.addDefaultIdentifierGenerator( idGenDef ); } ); @@ -143,6 +143,9 @@ public static void bindPackage(ClassLoaderService cls, String packageName, Metad bindNamedEntityGraphs( packageInfo, context ); } + else { + BOOT_LOGGER.packageNotFound( packageName ); + } } private static void bindNamedEntityGraphs(ClassDetails packageInfoClassDetails, MetadataBuildingContext context) { diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java index 65c0b3307f26..a98d12a44cb8 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java @@ -84,6 +84,7 @@ import static jakarta.persistence.ConstraintMode.PROVIDER_DEFAULT; import static jakarta.persistence.FetchType.LAZY; import static org.hibernate.annotations.CascadeType.DELETE_ORPHAN; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.boot.model.internal.AnnotatedClassType.EMBEDDABLE; import static org.hibernate.boot.model.internal.AnnotatedClassType.NONE; import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnFromAnnotation; @@ -110,7 +111,6 @@ import static org.hibernate.boot.model.internal.QueryBinder.bindQuery; import static org.hibernate.boot.models.annotations.internal.JoinColumnJpaAnnotation.toJoinColumn; import static org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle.fromResultCheckStyle; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; import static org.hibernate.internal.util.ReflectHelper.getDefaultSupplier; import static org.hibernate.internal.util.StringHelper.getNonEmptyOrConjunctionIfBothNonEmpty; import static org.hibernate.internal.util.StringHelper.isBlank; @@ -1057,8 +1057,8 @@ private void setDeclaringClass(ClassDetails declaringClass) { private void bind() { collection = createCollection( propertyHolder.getPersistentClass() ); final String role = qualify( propertyHolder.getPath(), propertyName ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Binding collection role: " + role ); + if ( BOOT_LOGGER.isTraceEnabled() ) { +BOOT_LOGGER.bindingCollectionRole( role ); } collection.setRole( role ); collection.setMappedByProperty( mappedBy ); @@ -1140,16 +1140,16 @@ private void detectMappedByProblem(boolean isMappedBy) { } if ( oneToMany ) { if ( property.hasDirectAnnotationUsage( MapKeyColumn.class ) ) { - CORE_LOGGER.warn( "Association '" - + qualify( propertyHolder.getPath(), propertyName ) - + "' is 'mappedBy' another entity and should not specify a '@MapKeyColumn'" - + " (use '@MapKey' instead)" ); + BOOT_LOGGER.warn( "Association '" + + qualify( propertyHolder.getPath(), propertyName ) + + "' is 'mappedBy' another entity and should not specify a '@MapKeyColumn'" + + " (use '@MapKey' instead)" ); } if ( property.hasDirectAnnotationUsage( OrderColumn.class ) ) { - CORE_LOGGER.warn( "Association '" - + qualify( propertyHolder.getPath(), propertyName ) - + "' is 'mappedBy' another entity and should not specify an '@OrderColumn'" - + " (use '@OrderBy' instead)" ); + BOOT_LOGGER.warn( "Association '" + + qualify( propertyHolder.getPath(), propertyName ) + + "' is 'mappedBy' another entity and should not specify an '@OrderColumn'" + + " (use '@OrderBy' instead)" ); } } else { @@ -2769,8 +2769,8 @@ private void setLocalGenerators(Map local } private void logOneToManySecondPass() { - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Binding one-to-many association through foreign key: " + safeCollectionRole() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { +BOOT_LOGGER.bindingOneToManyThroughForeignKey( safeCollectionRole() ); } } @@ -2778,18 +2778,18 @@ private void logManyToManySecondPass( boolean isOneToMany, boolean isCollectionOfEntities, boolean isManyToAny) { - if ( CORE_LOGGER.isTraceEnabled() ) { + if ( BOOT_LOGGER.isTraceEnabled() ) { if ( isCollectionOfEntities && isOneToMany ) { - CORE_LOGGER.trace( "Binding one-to-many association through association table: " + safeCollectionRole() ); + BOOT_LOGGER.bindingOneToManyThroughAssociationTable( safeCollectionRole() ); } else if ( isCollectionOfEntities ) { - CORE_LOGGER.trace( "Binding many-to-many association through association table: " + safeCollectionRole() ); + BOOT_LOGGER.bindingManyToManyThroughAssociationTable( safeCollectionRole() ); } else if ( isManyToAny ) { - CORE_LOGGER.trace( "Binding many-to-any: " + safeCollectionRole() ); + BOOT_LOGGER.bindingManyToAny( safeCollectionRole() ); } else { - CORE_LOGGER.trace( "Binding element collection to collection table: " + safeCollectionRole() ); + BOOT_LOGGER.bindingElementCollectionToCollectionTable( safeCollectionRole() ); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionPropertyHolder.java index 1238939902df..f752187e387f 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionPropertyHolder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionPropertyHolder.java @@ -36,7 +36,7 @@ import jakarta.persistence.OneToMany; import jakarta.persistence.Temporal; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.StringHelper.isEmpty; import static org.hibernate.internal.util.StringHelper.isNotEmpty; @@ -181,7 +181,7 @@ private static void logSpecNoncompliance(String attributeName, String role) { final boolean specCompliant = isNotEmpty( attributeName ) && (attributeName.startsWith( "key" ) || attributeName.startsWith( "value" ) ); if ( !specCompliant ) { - CORE_LOGGER.nonCompliantMapConversion( role ); + BOOT_LOGGER.nonCompliantMapConversion( role ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionSecondPass.java index dac138f77213..7a2c1526e8a1 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionSecondPass.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionSecondPass.java @@ -14,7 +14,7 @@ import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Value; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; /** * Collection second pass @@ -32,14 +32,14 @@ public CollectionSecondPass(Collection collection) { @Override public void doSecondPass(Map persistentClasses) throws MappingException { - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Second pass for collection: " + collection.getRole() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.secondPassForCollection( collection.getRole() ); } secondPass( persistentClasses ); collection.createAllKeys(); - if ( CORE_LOGGER.isTraceEnabled() ) { + if ( BOOT_LOGGER.isTraceEnabled() ) { String msg = "Mapped collection key: " + columns( collection.getKey() ); if ( collection.isIndexed() ) { msg += ", index: " + columns( ( (IndexedCollection) collection ).getIndex() ); @@ -51,7 +51,7 @@ public void doSecondPass(Map persistentClasses) else { msg += ", element: " + columns( collection.getElement() ); } - CORE_LOGGER.trace( msg ); + BOOT_LOGGER.mappedCollectionDetails( msg ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java index 30d085b227e2..d5d4e249ca43 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java @@ -69,7 +69,7 @@ import static org.hibernate.boot.model.internal.PropertyBinder.addElementsOfClass; import static org.hibernate.boot.model.internal.PropertyBinder.processElementAnnotations; import static org.hibernate.boot.model.internal.PropertyHolderBuilder.buildPropertyHolder; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.StringHelper.isBlank; import static org.hibernate.internal.util.StringHelper.qualify; import static org.hibernate.internal.util.StringHelper.unqualify; @@ -438,8 +438,8 @@ static Component fillEmbeddable( ); final String subpath = getPath( propertyHolder, inferredData ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Binding embeddable with path: " + subpath ); + if ( BOOT_LOGGER.isTraceEnabled() ) { +BOOT_LOGGER.bindingEmbeddable( subpath ); } final var subholder = buildPropertyHolder( embeddable, diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java index 079e0872b7de..696ec9bab2a5 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java @@ -111,7 +111,7 @@ import static org.hibernate.boot.model.naming.Identifier.toIdentifier; import static org.hibernate.engine.OptimisticLockStyle.fromLockType; import static org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle.fromResultCheckStyle; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.ReflectHelper.getDefaultSupplier; import static org.hibernate.internal.util.StringHelper.isBlank; import static org.hibernate.internal.util.StringHelper.isNotBlank; @@ -183,8 +183,8 @@ public static void bindEntityClass( ClassDetails clazzToProcess, Map inheritanceStates, MetadataBuildingContext context) { - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Binding entity with annotated class: " + clazzToProcess.getName() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.bindingEntityWithAnnotatedClass( clazzToProcess.getName() ); } final var collector = context.getMetadataCollector(); @@ -1025,9 +1025,8 @@ private boolean useDiscriminatorColumnForJoined(DiscriminatorColumn discriminato if ( discriminatorColumn != null ) { final boolean ignore = buildingOptions.ignoreExplicitDiscriminatorsForJoinedInheritance(); if ( ignore ) { - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Ignoring explicit @DiscriminatorColumn annotation on: " - + annotatedClass.getName() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.ignoringExplicitDiscriminatorForJoined( annotatedClass.getName() ); } } return !ignore; @@ -1035,9 +1034,8 @@ private boolean useDiscriminatorColumnForJoined(DiscriminatorColumn discriminato else { final boolean createImplicit = buildingOptions.createImplicitDiscriminatorsForJoinedInheritance(); if ( createImplicit ) { - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Inferring implicit @DiscriminatorColumn using defaults for: " - + annotatedClass.getName() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.inferringImplicitDiscriminatorForJoined( annotatedClass.getName() ); } } return createImplicit; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FilterDefBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FilterDefBinder.java index c07a951937e7..6afbdab51448 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FilterDefBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FilterDefBinder.java @@ -27,7 +27,7 @@ import static org.hibernate.boot.model.internal.AnnotationHelper.resolveBasicType; import static org.hibernate.boot.model.internal.AnnotationHelper.resolveJavaType; import static org.hibernate.boot.model.internal.AnnotationHelper.resolveUserType; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty; /** @@ -91,8 +91,8 @@ public static void bindFilterDef(FilterDef filterDef, MetadataBuildingContext co parameterResolvers ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Binding filter definition: " + filterDefinition.getFilterName() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { +BOOT_LOGGER.bindingFilterDefinition( filterDefinition.getFilterName() ); } context.getMetadataCollector().addFilterDefinition( filterDefinition ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java index e5aefe2f6bea..840fefd2b2d8 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java @@ -64,7 +64,7 @@ import static org.hibernate.boot.model.internal.GeneratorParameters.interpretTableGenerator; import static org.hibernate.boot.model.internal.GeneratorStrategies.generatorClass; import static org.hibernate.id.IdentifierGenerator.GENERATOR_NAME; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.NullnessUtil.castNonNull; import static org.hibernate.internal.util.StringHelper.isNotEmpty; import static org.hibernate.internal.util.StringHelper.qualify; @@ -296,9 +296,8 @@ private static IdentifierGeneratorDefinition buildIdGenerator(GenericGenerator g definitionBuilder.setStrategy( strategy ); definitionBuilder.addParams( extractParameterMap( generatorAnnotation.parameters() ) ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracev( "Added generator with name: {0}, strategy: {0}", - definitionBuilder.getName(), definitionBuilder.getStrategy() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.addedGenerator( definitionBuilder.getName(), definitionBuilder.getStrategy() ); } return definitionBuilder.build(); } @@ -306,8 +305,8 @@ private static IdentifierGeneratorDefinition buildIdGenerator(GenericGenerator g private static IdentifierGeneratorDefinition buildSequenceIdGenerator(SequenceGenerator generatorAnnotation) { final var definitionBuilder = new IdentifierGeneratorDefinition.Builder(); interpretSequenceGenerator( generatorAnnotation, definitionBuilder ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracev( "Added sequence generator with name: {0}", definitionBuilder.getName() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.addedSequenceGenerator( definitionBuilder.getName() ); } return definitionBuilder.build(); } @@ -315,8 +314,8 @@ private static IdentifierGeneratorDefinition buildSequenceIdGenerator(SequenceGe private static IdentifierGeneratorDefinition buildTableIdGenerator(TableGenerator generatorAnnotation) { final var definitionBuilder = new IdentifierGeneratorDefinition.Builder(); interpretTableGenerator( generatorAnnotation, definitionBuilder ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracev( "Added sequence generator with name: {0}", definitionBuilder.getName() ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.addedTableGenerator( definitionBuilder.getName() ); } return definitionBuilder.build(); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorParameters.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorParameters.java index 757d0fe35906..d7d54d1e3d7a 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorParameters.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorParameters.java @@ -43,7 +43,7 @@ import static org.hibernate.id.PersistentIdentifierGenerator.PK; import static org.hibernate.id.PersistentIdentifierGenerator.TABLE; import static org.hibernate.id.PersistentIdentifierGenerator.TABLES; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.StringHelper.isNotBlank; import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty; @@ -250,7 +250,7 @@ public static void interpretTableGenerator( // TODO : implement unique-constraint support if ( isNotEmpty( tableGeneratorAnnotation.uniqueConstraints() ) ) { - CORE_LOGGER.ignoringTableGeneratorConstraints( tableGeneratorAnnotation.name() ); + BOOT_LOGGER.ignoringTableGeneratorConstraints( tableGeneratorAnnotation.name() ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryBinder.java index 2376788a2f33..6c114cead078 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryBinder.java @@ -44,7 +44,7 @@ import java.util.function.Supplier; import static java.lang.Character.isWhitespace; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.StringHelper.nullIfEmpty; import static org.hibernate.internal.util.collections.ArrayHelper.isEmpty; import static org.hibernate.internal.util.collections.CollectionHelper.determineProperSizing; @@ -76,8 +76,8 @@ public static void bindQuery( "Class or package level '@NamedQuery' annotation must specify a 'name'" ); } - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( "Binding named query '%s' to [%s]", queryName, + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.bindingNamedQuery( queryName, queryString.replace( '\n', ' ' ) ); } @@ -134,12 +134,10 @@ public static void bindNativeQuery( final var resultClass = void.class == resultClassDetails ? null : resultClassDetails; final var queryDefinition = - createNamedQueryDefinition( registrationName, queryString, resultClass, resultSetMappingName, hints, - location ); - - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( "Binding named native query '%s' to [%s]", - queryDefinition.getRegistrationName(), + createNamedQueryDefinition( registrationName, queryString, resultClass, + resultSetMappingName, hints, location ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.bindingNamedNativeQuery( queryDefinition.getRegistrationName(), queryDefinition.getSqlQueryString().replace( '\n', ' ' ) ); } @@ -229,12 +227,9 @@ public static void bindNativeQuery( createQueryDefinition( namedNativeQuery, registrationName, resultSetMappingName, resultClass, namedNativeQuery.timeout(), namedNativeQuery.fetchSize(), querySpaces, location ); final var queryDefinition = builder.build(); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( - "Binding named native query '%' to [%s]", - queryDefinition.getRegistrationName(), - queryDefinition.getSqlQueryString().replace( '\n', ' ' ) - ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.bindingNamedNativeQuery( queryDefinition.getRegistrationName(), + queryDefinition.getSqlQueryString().replace( '\n', ' ' ) ); } context.getMetadataCollector().addNamedNativeQuery( queryDefinition ); } @@ -382,9 +377,8 @@ public static void bindQuery( final var hqlQueryDefinition = builder.build(); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( "Binding named query '%s' to [%s]", - hqlQueryDefinition.getRegistrationName(), + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.bindingNamedQuery( hqlQueryDefinition.getRegistrationName(), hqlQueryDefinition.getHqlString().replace( '\n', ' ' ) ); } @@ -446,7 +440,7 @@ public static void bindNamedStoredProcedureQuery( else { collector.addNamedProcedureCallDefinition( definition ); } - CORE_LOGGER.tracef( "Bound named stored procedure query: %s => %s", + BOOT_LOGGER.boundStoredProcedureQuery( definition.getRegistrationName(), definition.getProcedureName() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ResultSetMappingSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ResultSetMappingSecondPass.java index 8d2331a8f91a..f7e9007573ca 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ResultSetMappingSecondPass.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ResultSetMappingSecondPass.java @@ -35,7 +35,7 @@ public void doSecondPass(Map persistentClasses) throws return; } - final SqlResultSetMappingDescriptor mappingDefinition = SqlResultSetMappingDescriptor.from( annotation ); + final var mappingDefinition = SqlResultSetMappingDescriptor.from( annotation ); if ( isDefault ) { context.getMetadataCollector().addDefaultResultSetMapping( mappingDefinition ); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneBinder.java index 6257bf028c3e..697442fff068 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneBinder.java @@ -48,7 +48,7 @@ import static org.hibernate.boot.model.internal.BinderHelper.getPath; import static org.hibernate.boot.model.internal.BinderHelper.isDefault; import static org.hibernate.boot.model.internal.BinderHelper.handleForeignKeyConstraint; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.StringHelper.isBlank; import static org.hibernate.internal.util.StringHelper.nullIfEmpty; import static org.hibernate.internal.util.StringHelper.qualify; @@ -231,7 +231,7 @@ private static NotFoundAction notFoundAction(PropertyHolder propertyHolder, Memb final var notFound = property.getDirectAnnotationUsage( NotFound.class ); final NotFoundAction notFoundAction = notFound == null ? null : notFound.action(); if ( notFoundAction != null && fetchType == LAZY ) { - CORE_LOGGER.ignoreNotFoundWithFetchTypeLazy( propertyHolder.getEntityName(), property.getName() ); + BOOT_LOGGER.ignoreNotFoundWithFetchTypeLazy( propertyHolder.getEntityName(), property.getName() ); } return notFoundAction; } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ManagedResourcesImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ManagedResourcesImpl.java index d6c16f0af629..26c66cb294c7 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ManagedResourcesImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ManagedResourcesImpl.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; @@ -14,7 +13,6 @@ import java.util.Set; import org.hibernate.Internal; -import org.hibernate.boot.BootLogging; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.jaxb.spi.Binding; import org.hibernate.boot.jaxb.spi.JaxbBindableMappingDescriptor; @@ -26,7 +24,9 @@ import jakarta.persistence.AttributeConverter; import static java.util.Collections.unmodifiableCollection; +import static java.util.Collections.unmodifiableList; import static java.util.Collections.unmodifiableSet; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; /** @@ -56,14 +56,14 @@ private static void handleXmlMappings( ManagedResourcesImpl impl, BootstrapContext bootstrapContext) { if ( !bootstrapContext.getMetadataBuildingOptions().isXmlMappingEnabled() ) { - BootLogging.BOOT_LOGGER.debugf( - "Ignoring %s XML mappings due to `%s`", + BOOT_LOGGER.ignoringXmlMappings( sources.getMappingXmlBindings().size(), MappingSettings.XML_MAPPING_ENABLED ); - return; } - impl.mappingFileBindings.addAll( sources.getXmlBindings() ); + else { + impl.mappingFileBindings.addAll( sources.getXmlBindings() ); + } } public ManagedResourcesImpl() { @@ -91,7 +91,7 @@ public Collection getAnnotatedPackageNames() { @Override public Collection> getXmlMappingBindings() { - return Collections.unmodifiableList( mappingFileBindings ); + return unmodifiableList( mappingFileBindings ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/relational/Namespace.java b/hibernate-core/src/main/java/org/hibernate/boot/model/relational/Namespace.java index 131ee8166f40..9df90bc003bf 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/relational/Namespace.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/relational/Namespace.java @@ -33,7 +33,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcType; import org.hibernate.type.descriptor.jdbc.SqlTypedJdbcType; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; /** * Represents a namespace (named schema/catalog pair) with a Database and manages objects defined within. @@ -56,8 +56,7 @@ public Namespace(PhysicalNamingStrategy physicalNamingStrategy, JdbcEnvironment this.jdbcEnvironment = jdbcEnvironment; this.name = name; this.physicalName = physicalName( name, physicalNamingStrategy, jdbcEnvironment ); - - CORE_LOGGER.tracef( "Created database namespace [logicalName=%s, physicalName=%s]", name, physicalName ); + BOOT_LOGGER.createdDatabaseNamespace( name, physicalName ); } private static Name physicalName(Name name, PhysicalNamingStrategy physicalNaming, JdbcEnvironment environment) { @@ -95,11 +94,10 @@ public Table locateTable(Identifier logicalTableName) { public void registerTable(Identifier logicalName, Table table) { final Table previous = tables.put( logicalName, table ); if ( previous != null ) { - CORE_LOGGER.debugf( - "Replacing Table registration(%s) : %s -> %s", - logicalName, - previous, - table + BOOT_LOGGER.replacingTableRegistration( + String.valueOf(logicalName), + String.valueOf(previous), + String.valueOf(table) ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java index efcc702e29e2..79ccc3381777 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java @@ -7,41 +7,38 @@ import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; -import java.util.Map; import java.util.Set; import org.hibernate.MappingException; import org.hibernate.boot.internal.MetadataBuildingContextRootImpl; import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl; import org.hibernate.boot.model.convert.internal.ConverterDescriptors; -import org.hibernate.boot.model.convert.spi.ConverterRegistry; import org.hibernate.boot.model.convert.spi.RegisteredConversion; import org.hibernate.boot.model.internal.AnnotationBinder; -import org.hibernate.boot.model.internal.InheritanceState; import org.hibernate.boot.model.process.spi.ManagedResources; -import org.hibernate.boot.model.process.spi.MetadataBuildingProcess; import org.hibernate.boot.model.source.spi.MetadataSourceProcessor; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; -import org.hibernate.boot.spi.BootstrapContext; -import org.hibernate.boot.spi.InFlightMetadataCollector; import org.hibernate.boot.spi.JpaOrmXmlPersistenceUnitDefaultAware; -import org.hibernate.boot.spi.MappingDefaults; import org.hibernate.boot.spi.MetadataBuildingOptions; import org.hibernate.models.spi.ClassDetails; -import org.hibernate.models.spi.ClassDetailsRegistry; -import org.jboss.logging.Logger; import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; +import static org.hibernate.boot.model.internal.AnnotationBinder.bindClass; +import static org.hibernate.boot.model.internal.AnnotationBinder.bindDefaults; +import static org.hibernate.boot.model.internal.AnnotationBinder.bindFetchProfilesForClass; +import static org.hibernate.boot.model.internal.AnnotationBinder.bindFetchProfilesForPackage; +import static org.hibernate.boot.model.internal.AnnotationBinder.buildInheritanceStates; +import static org.hibernate.boot.model.process.spi.MetadataBuildingProcess.processManagedResources; + /** * @author Steve Ebersole */ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProcessor { - private static final Logger LOG = Logger.getLogger( AnnotationMetadataSourceProcessorImpl.class ); - // NOTE : we de-categorize the classes into a single collection (xClasses) here to work with the - // existing "binder" infrastructure. + // NOTE: we decategorize the classes into a single collection (xClasses) + // here to work with the existing "binder" infrastructure. // todo : once we move to the phased binding approach, come back and handle that private final DomainModelSource domainModelSource; @@ -62,15 +59,15 @@ public AnnotationMetadataSourceProcessorImpl( this.domainModelSource = domainModelSource; this.rootMetadataBuildingContext = rootMetadataBuildingContext; - final BootstrapContext bootstrapContext = rootMetadataBuildingContext.getBootstrapContext(); + final var bootstrapContext = rootMetadataBuildingContext.getBootstrapContext(); classLoaderService = bootstrapContext.getClassLoaderService(); assert classLoaderService != null; - final ConverterRegistry converterRegistry = + final var converterRegistry = rootMetadataBuildingContext.getMetadataCollector().getConverterRegistry(); domainModelSource.getConversionRegistrations().forEach( (registration) -> { - final Class explicitDomainType = registration.getExplicitDomainType(); + final var explicitDomainType = registration.getExplicitDomainType(); converterRegistry.addRegisteredConversion( new RegisteredConversion( explicitDomainType == void.class || explicitDomainType == Void.class ? void.class @@ -90,11 +87,11 @@ public AnnotationMetadataSourceProcessorImpl( applyManagedClasses( domainModelSource, knownClasses ); - final ClassDetailsRegistry classDetailsRegistry = domainModelSource.getClassDetailsRegistry(); + final var classDetailsRegistry = domainModelSource.getClassDetailsRegistry(); for ( String className : managedResources.getAnnotatedClassNames() ) { knownClasses.add( classDetailsRegistry.resolveClassDetails( className ) ); } - for ( Class annotatedClass : managedResources.getAnnotatedClassReferences() ) { + for ( var annotatedClass : managedResources.getAnnotatedClassReferences() ) { knownClasses.add( classDetailsRegistry.resolveClassDetails( annotatedClass.getName() ) ); } @@ -111,21 +108,20 @@ public static void processAdditionalMappings( List additionalJaxbMappings, MetadataBuildingContextRootImpl rootMetadataBuildingContext, MetadataBuildingOptions options) { - final AdditionalManagedResourcesImpl.Builder mrBuilder = new AdditionalManagedResourcesImpl.Builder( - rootMetadataBuildingContext.getBootstrapContext().getServiceRegistry() - ); - mrBuilder.addLoadedClasses( additionalClasses ); - mrBuilder.addClassDetails( additionalClassDetails ); - mrBuilder.addJaxbEntityMappings( additionalJaxbMappings ); - - final ManagedResources mr = mrBuilder.build(); - final DomainModelSource additionalDomainModelSource = MetadataBuildingProcess.processManagedResources( - mr, - rootMetadataBuildingContext.getMetadataCollector(), - rootMetadataBuildingContext.getBootstrapContext(), - options.getMappingDefaults() - ); - new AnnotationMetadataSourceProcessorImpl( mr, additionalDomainModelSource, rootMetadataBuildingContext ) + final var builder = + new AdditionalManagedResourcesImpl.Builder( + rootMetadataBuildingContext.getBootstrapContext().getServiceRegistry() ); + builder.addLoadedClasses( additionalClasses ); + builder.addClassDetails( additionalClassDetails ); + builder.addJaxbEntityMappings( additionalJaxbMappings ); + + final var managedResources = builder.build(); + final var additionalDomainModelSource = + processManagedResources( managedResources, + rootMetadataBuildingContext.getMetadataCollector(), + rootMetadataBuildingContext.getBootstrapContext(), + options.getMappingDefaults() ); + new AnnotationMetadataSourceProcessorImpl( managedResources, additionalDomainModelSource, rootMetadataBuildingContext ) .processEntityHierarchies( new LinkedHashSet<>() ); } @@ -135,11 +131,11 @@ public void prepare() { ( (JpaOrmXmlPersistenceUnitDefaultAware) rootMetadataBuildingContext.getBuildingOptions() ) .apply( domainModelSource.getPersistenceUnitMetadata() ); - final MappingDefaults defaults = rootMetadataBuildingContext.getBuildingOptions().getMappingDefaults(); + final var defaults = rootMetadataBuildingContext.getBuildingOptions().getMappingDefaults(); rootMetadataBuildingContext.getMetadataCollector().getDatabase() .adjustDefaultNamespace( defaults.getImplicitCatalogName(), defaults.getImplicitSchemaName() ); - AnnotationBinder.bindDefaults( rootMetadataBuildingContext ); + bindDefaults( rootMetadataBuildingContext ); for ( String annotatedPackage : annotatedPackages ) { AnnotationBinder.bindPackage( classLoaderService, annotatedPackage, rootMetadataBuildingContext ); } @@ -167,7 +163,7 @@ public void processIdentifierGenerators() { @Override public void processFilterDefinitions() { - final InFlightMetadataCollector collector = rootMetadataBuildingContext.getMetadataCollector(); + final var collector = rootMetadataBuildingContext.getMetadataCollector(); for ( var registration : domainModelSource.getGlobalRegistrations().getFilterDefRegistrations().values() ) { collector.addFilterDefinition( registration.toFilterDefinition( rootMetadataBuildingContext ) ); } @@ -183,20 +179,16 @@ public void prepareForEntityHierarchyProcessing() { @Override public void processEntityHierarchies(Set processedEntityNames) { - final List orderedClasses = orderAndFillHierarchy( knownClasses ); - final Map inheritanceStatePerClass = - AnnotationBinder.buildInheritanceStates( orderedClasses, rootMetadataBuildingContext ); - - for ( ClassDetails clazz : orderedClasses ) { - if ( processedEntityNames.contains( clazz.getName() ) ) { - LOG.debugf( "Skipping annotated class processing of entity [%s], as it has already been processed", clazz ); - } - else { - if ( !clazz.getName().endsWith( ".package-info" ) ) { - AnnotationBinder.bindClass( clazz, inheritanceStatePerClass, rootMetadataBuildingContext ); - AnnotationBinder.bindFetchProfilesForClass( clazz, rootMetadataBuildingContext ); - processedEntityNames.add( clazz.getName() ); - } + final var orderedClasses = orderAndFillHierarchy( knownClasses ); + final var inheritanceStatePerClass = + buildInheritanceStates( orderedClasses, rootMetadataBuildingContext ); + + for ( var clazz : orderedClasses ) { + if ( !processedEntityNames.contains( clazz.getName() ) + && !clazz.getName().endsWith( ".package-info" ) ) { + bindClass( clazz, inheritanceStatePerClass, rootMetadataBuildingContext ); + bindFetchProfilesForClass( clazz, rootMetadataBuildingContext ); + processedEntityNames.add( clazz.getName() ); } } } @@ -208,29 +200,20 @@ private List orderAndFillHierarchy(LinkedHashSet ori final List workingCopy = new ArrayList<>( copy ); final List newList = new ArrayList<>( copy.size() ); while ( !workingCopy.isEmpty() ) { - final ClassDetails clazz = workingCopy.get( 0 ); + final var clazz = workingCopy.get( 0 ); orderHierarchy( workingCopy, newList, copy, clazz ); } return newList; } private void insertMappedSuperclasses(LinkedHashSet original, LinkedHashSet copy) { - final boolean traceEnabled = LOG.isTraceEnabled(); - - for ( ClassDetails clazz : original ) { - if ( clazz.isInterface() ) { - if ( clazz.hasDirectAnnotationUsage( Entity.class ) ) { - throw new MappingException( "Only classes (not interfaces) may be mapped as @Entity : " + clazz.getName() ); - } + for ( var clazz : original ) { + if ( clazz.isInterface() && clazz.hasDirectAnnotationUsage( Entity.class ) ) { + throw new MappingException( "Interface '" + clazz.getName() + "' may not be annotated '@Entity'" ); } - - if ( clazz.hasDirectAnnotationUsage( MappedSuperclass.class ) ) { - if ( traceEnabled ) { - LOG.tracef( - "Skipping explicit MappedSuperclass %s, the class will be discovered analyzing the implementing class", - clazz - ); - } + else if ( clazz.hasDirectAnnotationUsage( MappedSuperclass.class ) ) { + // Skip class with explicit @MappedSuperclass annotation + // the class will be discovered analyzing the implementing class } else { copy.add( clazz ); @@ -264,7 +247,7 @@ private void orderHierarchy(List copy, List newList, @Override public void postProcessEntityHierarchies() { for ( String annotatedPackage : annotatedPackages ) { - AnnotationBinder.bindFetchProfilesForPackage( annotatedPackage, rootMetadataBuildingContext ); + bindFetchProfilesForPackage( annotatedPackage, rootMetadataBuildingContext ); } } @@ -279,7 +262,7 @@ public void finishUp() { private static void applyManagedClasses( DomainModelSource domainModelSource, LinkedHashSet knownClasses) { - final ClassDetailsRegistry classDetailsRegistry = domainModelSource.getClassDetailsRegistry(); + final var classDetailsRegistry = domainModelSource.getClassDetailsRegistry(); domainModelSource.getManagedClassNames().forEach( (className) -> { knownClasses.add( classDetailsRegistry.resolveClassDetails( className ) ); } ); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java index 8c209ebffe99..b00fa0fc842f 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java @@ -36,7 +36,6 @@ import org.hibernate.boot.model.naming.ImplicitNamingStrategy; import org.hibernate.boot.model.naming.ImplicitUniqueKeyNameSource; import org.hibernate.boot.model.relational.Database; -import org.hibernate.boot.model.relational.Namespace; import org.hibernate.boot.model.source.internal.ImplicitColumnNamingSecondPass; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.boot.spi.BootstrapContext; @@ -104,7 +103,7 @@ import static org.hibernate.boot.model.source.internal.hbm.Helper.reflectedPropertyClass; import static org.hibernate.boot.model.source.internal.hbm.NamedQueryBinder.processNamedNativeQuery; import static org.hibernate.boot.model.source.internal.hbm.NamedQueryBinder.processNamedQuery; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER; import static org.hibernate.internal.util.StringHelper.getNonEmptyOrConjunctionIfBothNonEmpty; import static org.hibernate.internal.util.StringHelper.isNotEmpty; @@ -139,9 +138,9 @@ public ModelBinder(final MetadataBuildingContext context) { } public void bindEntityHierarchy(EntityHierarchySourceImpl hierarchySource) { - final RootClass rootEntityDescriptor = new RootClass( hierarchySource.getRootEntityMappingDocument() ); + final var rootEntityDescriptor = new RootClass( hierarchySource.getRootEntityMappingDocument() ); bindRootEntity( hierarchySource, rootEntityDescriptor ); - final RootEntitySourceImpl root = hierarchySource.getRoot(); + final var root = hierarchySource.getRoot(); root.getLocalMetadataBuildingContext().getMetadataCollector() .addEntityBinding( rootEntityDescriptor ); @@ -162,8 +161,8 @@ public void bindEntityHierarchy(EntityHierarchySourceImpl hierarchySource) { } private void bindRootEntity(EntityHierarchySourceImpl hierarchySource, RootClass rootEntityDescriptor) { - final RootEntitySourceImpl root = hierarchySource.getRoot(); - final MappingDocument mappingDocument = root.sourceMappingDocument(); + final var root = hierarchySource.getRoot(); + final var mappingDocument = root.sourceMappingDocument(); bindBasicEntityValues( mappingDocument, root, rootEntityDescriptor ); @@ -176,8 +175,8 @@ private void bindRootEntity(EntityHierarchySourceImpl hierarchySource, RootClass ); rootEntityDescriptor.setTable( primaryTable ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( "Mapping class: %s -> %s", + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.mappingClassToTable( rootEntityDescriptor.getEntityName(), primaryTable.getName() ); } @@ -317,7 +316,7 @@ private void bindBasicEntityValues( entityDescriptor.addSynchronizedTable( physicalTableName( sourceDocument, tableName ) ); } - for ( FilterSource filterSource : entitySource.getFilterSources() ) { + for ( var filterSource : entitySource.getFilterSources() ) { entityDescriptor.addFilter( filterSource.getName(), filterCondition( filterSource, sourceDocument ), @@ -393,8 +392,8 @@ private String physicalTableName(MappingDocument sourceDocument, String tableNam private void bindDiscriminatorSubclassEntities( AbstractEntitySourceImpl entitySource, PersistentClass superEntityDescriptor) { - for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) { - final SingleTableSubclass subEntityDescriptor = + for ( var subType : entitySource.getSubTypes() ) { + final var subEntityDescriptor = new SingleTableSubclass( superEntityDescriptor, metadataBuildingContext ); subEntityDescriptor.setCached( superEntityDescriptor.isCached() ); bindDiscriminatorSubclassEntity( (SubclassEntitySourceImpl) subType, subEntityDescriptor ); @@ -408,7 +407,7 @@ private void bindDiscriminatorSubclassEntity( SubclassEntitySourceImpl entitySource, SingleTableSubclass entityDescriptor) { - final MappingDocument sourceDocument = entitySource.sourceMappingDocument(); + final var sourceDocument = entitySource.sourceMappingDocument(); final var localMetadataCollector = entitySource.getLocalMetadataBuildingContext().getMetadataCollector(); bindBasicEntityValues( sourceDocument, entitySource, entityDescriptor ); @@ -431,8 +430,8 @@ private void bindDiscriminatorSubclassEntity( private void bindJoinedSubclassEntities( AbstractEntitySourceImpl entitySource, PersistentClass superEntityDescriptor) { - for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) { - final JoinedSubclass subEntityDescriptor = + for ( var subType : entitySource.getSubTypes() ) { + final var subEntityDescriptor = new JoinedSubclass( superEntityDescriptor, metadataBuildingContext ); subEntityDescriptor.setCached( superEntityDescriptor.isCached() ); bindJoinedSubclassEntity( (JoinedSubclassEntitySourceImpl) subType, subEntityDescriptor ); @@ -445,7 +444,7 @@ private void bindJoinedSubclassEntities( private void bindJoinedSubclassEntity( JoinedSubclassEntitySourceImpl entitySource, JoinedSubclass entityDescriptor) { - final MappingDocument mappingDocument = entitySource.sourceMappingDocument(); + final var mappingDocument = entitySource.sourceMappingDocument(); bindBasicEntityValues( mappingDocument, entitySource, entityDescriptor ); @@ -458,8 +457,8 @@ private void bindJoinedSubclassEntity( ); entityDescriptor.setTable( primaryTable ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( "Mapping joined-subclass: %s -> %s", + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.mappingJoinedSubclassToTable( entityDescriptor.getEntityName(), primaryTable.getName() ); } @@ -501,8 +500,8 @@ public Identifier determineImplicitName(LocalMetadataBuildingContext context) { private void bindUnionSubclassEntities( EntitySource entitySource, PersistentClass superEntityDescriptor) { - for ( IdentifiableTypeSource subType : entitySource.getSubTypes() ) { - final UnionSubclass subEntityDescriptor = + for ( var subType : entitySource.getSubTypes() ) { + final var subEntityDescriptor = new UnionSubclass( superEntityDescriptor, metadataBuildingContext ); subEntityDescriptor.setCached( superEntityDescriptor.isCached() ); bindUnionSubclassEntity( (SubclassEntitySourceImpl) subType, subEntityDescriptor ); @@ -515,7 +514,7 @@ private void bindUnionSubclassEntities( private void bindUnionSubclassEntity( SubclassEntitySourceImpl entitySource, UnionSubclass entityDescriptor) { - final MappingDocument mappingDocument = entitySource.sourceMappingDocument(); + final var mappingDocument = entitySource.sourceMappingDocument(); bindBasicEntityValues( mappingDocument, entitySource, entityDescriptor ); @@ -528,8 +527,8 @@ private void bindUnionSubclassEntity( ); entityDescriptor.setTable( primaryTable ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( "Mapping union-subclass: %s -> %s", + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.mappingUnionSubclassToTable( entityDescriptor.getEntityName(), primaryTable.getName() ); } @@ -549,9 +548,9 @@ private void bindSimpleEntityIdentifier( MappingDocument sourceDocument, final EntityHierarchySourceImpl hierarchySource, RootClass rootEntityDescriptor) { - final IdentifierSourceSimple idSource = (IdentifierSourceSimple) hierarchySource.getIdentifierSource(); + final var idSource = (IdentifierSourceSimple) hierarchySource.getIdentifierSource(); - final BasicValue idValue = new BasicValue( sourceDocument, rootEntityDescriptor.getTable() ); + final var idValue = new BasicValue( sourceDocument, rootEntityDescriptor.getTable() ); rootEntityDescriptor.setIdentifier( idValue ); bindSimpleValueType( @@ -602,7 +601,7 @@ public MetadataBuildingContext getBuildingContext() { ); if ( propertyName != null ) { - final Property property = new Property(); + final var property = new Property(); property.setValue( idValue ); bindProperty( sourceDocument, idSource.getIdentifierAttributeSource(), property ); rootEntityDescriptor.setIdentifierProperty( property ); @@ -632,7 +631,7 @@ private void bindAggregatedCompositeEntityIdentifier( (IdentifierSourceAggregatedComposite) hierarchySource.getIdentifierSource(); - final Component cid = new Component( mappingDocument, rootEntityDescriptor ); + final var cid = new Component( mappingDocument, rootEntityDescriptor ); cid.setKey( true ); rootEntityDescriptor.setIdentifier( cid ); @@ -678,13 +677,13 @@ private void bindNonAggregatedCompositeEntityIdentifier( (IdentifierSourceNonAggregatedComposite) hierarchySource.getIdentifierSource(); - final Component cid = new Component( mappingDocument, rootEntityDescriptor ); + final var cid = new Component( mappingDocument, rootEntityDescriptor ); cid.setKey( true ); rootEntityDescriptor.setIdentifier( cid ); final String idClassName = extractIdClassName( identifierSource ); - final AttributeRole attributeRoleBase = hierarchySource.getRoot().getAttributeRoleBase(); + final var attributeRoleBase = hierarchySource.getRoot().getAttributeRoleBase(); final String className = rootEntityDescriptor.getClassName(); bindComponent( @@ -704,7 +703,7 @@ private void bindNonAggregatedCompositeEntityIdentifier( // We also need to bind the "id mapper". Ugh, terrible name. Basically, // we need to create a virtual (embedded) composite for the non-aggregated // attributes on the entity itself. - final Component mapper = new Component( mappingDocument, rootEntityDescriptor ); + final var mapper = new Component( mappingDocument, rootEntityDescriptor ); bindComponent( mappingDocument, attributeRoleBase.append( ID_MAPPER_PATH_PART ).getFullPath(), @@ -720,7 +719,7 @@ private void bindNonAggregatedCompositeEntityIdentifier( rootEntityDescriptor.setIdentifierMapper( mapper ); rootEntityDescriptor.setDeclaredIdentifierMapper( mapper ); - final Property property = new Property(); + final var property = new Property(); property.setName( NavigablePath.IDENTIFIER_MAPPER_PROPERTY ); property.setUpdatable( false ); property.setInsertable( false ); @@ -762,7 +761,7 @@ private void finishBindingCompositeIdentifier( } } else { - final Property property = new Property(); + final var property = new Property(); property.setValue( cid ); bindProperty( sourceDocument, @@ -788,7 +787,7 @@ private void bindEntityVersion( RootClass rootEntityDescriptor) { final var versionAttributeSource = hierarchySource.getVersionAttributeSource(); - final BasicValue versionValue = + final var versionValue = new BasicValue( sourceDocument, rootEntityDescriptor.getTable() ); versionValue.makeVersion(); @@ -803,7 +802,7 @@ private void bindEntityVersion( context -> implicitNamingStrategy.determineBasicColumnName( versionAttributeSource ) ); - final Property property = new Property(); + final var property = new Property(); property.setValue( versionValue ); bindProperty( sourceDocument, versionAttributeSource, property ); @@ -828,11 +827,11 @@ private void bindEntityDiscriminator( MappingDocument sourceDocument, final EntityHierarchySourceImpl hierarchySource, RootClass rootEntityDescriptor) { - final BasicValue discriminatorValue = + final var discriminatorValue = new BasicValue( sourceDocument, rootEntityDescriptor.getTable() ); rootEntityDescriptor.setDiscriminator( discriminatorValue ); - final DiscriminatorSource discriminatorSource = hierarchySource.getDiscriminatorSource(); + final var discriminatorSource = hierarchySource.getDiscriminatorSource(); String typeName = discriminatorSource.getExplicitHibernateTypeName(); if ( typeName == null ) { @@ -862,7 +861,7 @@ private void bindAllEntityAttributes( MappingDocument mappingDocument, EntitySource entitySource, PersistentClass entityDescriptor) { - final EntityTableXref entityTableXref = + final var entityTableXref = mappingDocument.getMetadataCollector() .getEntityTableXref( entityDescriptor.getEntityName() ); if ( entityTableXref == null ) { @@ -884,10 +883,10 @@ private void bindAllEntityAttributes( entityDescriptor.addJoin( secondaryTableJoin ); } - for ( AttributeSource attributeSource : entitySource.attributeSources() ) { + for ( var attributeSource : entitySource.attributeSources() ) { if ( attributeSource instanceof PluralAttributeSource pluralAttributeSource) { // plural attribute - final Property attribute = + final var attribute = createPluralAttribute( mappingDocument, pluralAttributeSource, entityDescriptor ); attribute.setOptional( true ); entityDescriptor.addProperty( attribute ); @@ -909,7 +908,7 @@ private void bindAllEntityAttributes( attributeContainer = secondaryTableJoin; } - final Property attribute = createBasicAttribute( + final var attribute = createBasicAttribute( mappingDocument, basicAttributeSource, new BasicValue( mappingDocument, table ), @@ -937,7 +936,7 @@ else if ( attributeSource instanceof SingularAttributeSourceEmbedded embeddedAtt attributeContainer = secondaryTableJoin; } - final Property attribute = createEmbeddedAttribute( + final var attribute = createEmbeddedAttribute( mappingDocument, embeddedAttributeSource, new Component( mappingDocument, table, entityDescriptor ), @@ -966,7 +965,7 @@ else if ( attributeSource instanceof SingularAttributeSourceManyToOne manyToOneA attributeContainer = secondaryTableJoin; } - final Property attribute = createManyToOneAttribute( + final var attribute = createManyToOneAttribute( mappingDocument, manyToOneAttributeSource, new ManyToOne( mappingDocument, table ), @@ -982,7 +981,7 @@ else if ( attributeSource instanceof SingularAttributeSourceManyToOne manyToOneA } else if ( attributeSource instanceof SingularAttributeSourceOneToOne oneToOneAttributeSource ) { final Table table = entityDescriptor.getTable(); - final Property attribute = createOneToOneAttribute( + final var attribute = createOneToOneAttribute( mappingDocument, oneToOneAttributeSource, new OneToOne( mappingDocument, table, entityDescriptor ), @@ -1014,7 +1013,7 @@ else if ( attributeSource instanceof SingularAttributeSourceAny anyAttributeSour attributeContainer = secondaryTableJoin; } - final Property attribute = createAnyAssociationAttribute( + final var attribute = createAnyAssociationAttribute( mappingDocument, anyAttributeSource, new Any( mappingDocument, table ), @@ -1115,7 +1114,7 @@ else if ( attributeSource instanceof PluralAttributeSourceIdBagImpl ) { ); } else if ( attributeSource instanceof PluralAttributeSourceArrayImpl arraySource ) { - final Array array = new Array(sourceDocument, entityDescriptor); + final var array = new Array(sourceDocument, entityDescriptor); collectionBinding = array; bindCollectionMetadata( sourceDocument, attributeSource, collectionBinding ); @@ -1127,7 +1126,7 @@ else if ( attributeSource instanceof PluralAttributeSourceArrayImpl arraySource ); } else if ( attributeSource instanceof PluralAttributeSourcePrimitiveArrayImpl pluralAttributeSourcePrimitiveArray ) { - final PrimitiveArray primitiveArray = new PrimitiveArray( sourceDocument, entityDescriptor ); + final var primitiveArray = new PrimitiveArray( sourceDocument, entityDescriptor ); collectionBinding = primitiveArray; bindCollectionMetadata( sourceDocument, attributeSource, collectionBinding ); @@ -1148,7 +1147,7 @@ else if ( attributeSource instanceof PluralAttributeSourcePrimitiveArrayImpl plu sourceDocument.getMetadataCollector().addCollectionBinding( collectionBinding ); - final Property attribute = new Property(); + final var attribute = new Property(); attribute.setValue( collectionBinding ); bindProperty( sourceDocument, attributeSource, attribute ); @@ -1321,7 +1320,7 @@ private Identifier determineTable( MappingDocument mappingDocument, SingularAttributeSourceEmbedded embeddedAttributeSource) { Identifier tableName = null; - for ( AttributeSource attributeSource : embeddedAttributeSource.getEmbeddableSource().attributeSources() ) { + for ( var attributeSource : embeddedAttributeSource.getEmbeddableSource().attributeSources() ) { final Identifier determinedName; if ( attributeSource instanceof RelationalValueSourceContainer relationalValueSourceContainer ) { determinedName = determineTable( @@ -1370,7 +1369,7 @@ private Identifier determineTable( String attributeName, List relationalValueSources) { String tableName = null; - for ( RelationalValueSource relationalValueSource : relationalValueSources ) { + for ( var relationalValueSource : relationalValueSources ) { // We need to get the containing table name for both columns and formulas, // particularly when a column/formula is for a property on a secondary table. if ( !Objects.equals( tableName, relationalValueSource.getContainingTableName() ) ) { @@ -1399,11 +1398,11 @@ private void bindSecondaryTable( SecondaryTableSource secondaryTableSource, Join secondaryTableJoin, final EntityTableXref entityTableXref) { - final PersistentClass persistentClass = secondaryTableJoin.getPersistentClass(); + final var persistentClass = secondaryTableJoin.getPersistentClass(); final Identifier catalogName = determineCatalogName( secondaryTableSource.getTableSource() ); final Identifier schemaName = determineSchemaName( secondaryTableSource.getTableSource() ); - final Namespace namespace = database.locateNamespace( catalogName, schemaName ); + final var namespace = database.locateNamespace( catalogName, schemaName ); Table secondaryTable; final Identifier logicalTableName; @@ -1442,15 +1441,14 @@ private void bindSecondaryTable( secondaryTableJoin.setInverse( secondaryTableSource.isInverse() ); secondaryTableJoin.setOptional( secondaryTableSource.isOptional() ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( - "Mapping entity secondary-table: %s -> %s", + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.mappingEntitySecondaryTableToTable( persistentClass.getEntityName(), secondaryTable.getName() ); } - final DependantValue keyBinding = + final var keyBinding = new DependantValue( mappingDocument, secondaryTable, persistentClass.getIdentifier() ); if ( mappingDocument.getBuildingOptions().useNationalizedCharacterData() ) { keyBinding.makeNationalized(); @@ -1525,7 +1523,7 @@ private Property createEmbeddedAttribute( componentBinding.createForeignKey(); - final Property attribute = new Property(); + final var attribute = new Property(); attribute.setValue( componentBinding ); bindProperty( sourceDocument, embeddedSource, attribute ); if ( embeddedSource.isVirtualAttribute() ) { @@ -1583,7 +1581,7 @@ private Property createBasicAttribute( value.createForeignKey(); - final Property property = new Property(); + final var property = new Property(); property.setValue( value ); property.setLob( value.isLob() ); bindProperty( sourceDocument, attributeSource, property ); @@ -1595,8 +1593,8 @@ private void resolveLob(final SingularAttributeSourceBasic attributeSource, Simp // Essentially, this expects the type to map to a CLOB/NCLOB/BLOB SQL type internally and compares. if ( !value.isLob() && value.getTypeName() != null ) { final String typeName = value.getTypeName(); - final MetadataBuildingContext context = attributeSource.getBuildingContext(); - final BasicType basicType = + final var context = attributeSource.getBuildingContext(); + final var basicType = typeName.startsWith( BasicTypeImpl.EXTERNALIZED_PREFIX ) ? context.getBootstrapContext().resolveAdHocBasicType( typeName ) : context.getMetadataCollector().getTypeConfiguration() @@ -1667,7 +1665,7 @@ private Property createOneToOneAttribute( // so that we can observe the properties/columns of a possible component in the correct order metadataBuildingContext.getMetadataCollector().addSecondPass( new OneToOneFkSecondPass( oneToOneBinding ) ); - final Property property = new Property(); + final var property = new Property(); property.setValue( oneToOneBinding ); bindProperty( sourceDocument, oneToOneSource, property ); return property; @@ -1678,8 +1676,9 @@ private void handlePropertyReference( String referencedEntityName, String referencedPropertyName, String sourceElementSynopsis) { - final PersistentClass entityBinding = - mappingDocument.getMetadataCollector().getEntityBinding( referencedEntityName ); + final var entityBinding = + mappingDocument.getMetadataCollector() + .getEntityBinding( referencedEntityName ); if ( entityBinding == null ) { // entity may just not have been processed yet - set up a delayed handler registerDelayedPropertyReferenceHandler( @@ -1694,7 +1693,7 @@ private void handlePropertyReference( ); } else { - final Property propertyBinding = + final var propertyBinding = entityBinding.getReferencedProperty( referencedPropertyName ); if ( propertyBinding == null ) { // attribute may just not have been processed yet - set up a delayed handler @@ -1710,7 +1709,7 @@ private void handlePropertyReference( ); } else { - CORE_LOGGER.tracef( + BOOT_LOGGER.tracef( "Property [%s.%s] referenced by property-ref [%s] was available - no need for delayed handling", referencedEntityName, referencedPropertyName, @@ -1724,7 +1723,7 @@ private void handlePropertyReference( private void registerDelayedPropertyReferenceHandler( DelayedPropertyReferenceHandlerImpl handler, MetadataBuildingContext buildingContext) { - CORE_LOGGER.tracef( + BOOT_LOGGER.tracef( "Property [%s.%s] referenced by property-ref [%s] was not yet available - creating delayed handler", handler.referencedEntityName, handler.referencedPropertyName, @@ -1811,7 +1810,7 @@ private Property createManyToOneAttribute( referencedEntityName = explicitReferencedEntityName; } else { - final Class reflectedPropertyClass = + final var reflectedPropertyClass = reflectedPropertyClass( sourceDocument, containingClassName, attributeName ); if ( reflectedPropertyClass != null ) { referencedEntityName = reflectedPropertyClass.getName(); @@ -1844,7 +1843,7 @@ private Property createManyToOneAttribute( ); } - final Property property = new Property(); + final var property = new Property(); property.setValue( manyToOneBinding ); bindProperty( sourceDocument, manyToOneSource, property ); @@ -1911,7 +1910,7 @@ private void bindManyToOneAttribute( setForeignKeyName( manyToOneBinding, manyToOneSource.getExplicitForeignKeyName() ); - final ManyToOneColumnBinder columnBinder = new ManyToOneColumnBinder( + final var columnBinder = new ManyToOneColumnBinder( sourceDocument, manyToOneSource, manyToOneBinding, @@ -1928,7 +1927,7 @@ private void bindManyToOneAttribute( if ( !manyToOneSource.isIgnoreNotFound() ) { // we skip creating the FK here since this setting tells us there // cannot be a suitable/proper FK - final ManyToOneFkSecondPass fkSecondPass = new ManyToOneFkSecondPass( + final var fkSecondPass = new ManyToOneFkSecondPass( sourceDocument, manyToOneSource, manyToOneBinding, @@ -1963,15 +1962,15 @@ private Property createAnyAssociationAttribute( Any anyBinding, String entityName) { - final AttributeRole role = anyMapping.getAttributeRole(); + final var attributeRole = anyMapping.getAttributeRole(); - bindAny( sourceDocument, anyMapping, anyBinding, role ); + bindAny( sourceDocument, anyMapping, anyBinding, attributeRole ); - prepareValueTypeViaReflection( sourceDocument, anyBinding, entityName, anyMapping.getName(), role ); + prepareValueTypeViaReflection( sourceDocument, anyBinding, entityName, anyMapping.getName(), attributeRole ); anyBinding.createForeignKey(); - final Property property = new Property(); + final var property = new Property(); property.setValue( anyBinding ); bindProperty( sourceDocument, anyMapping, property ); return property; @@ -1985,13 +1984,13 @@ private void bindAny( anyBinding.setLazy( anyMapping.isLazy() ); - final TypeResolution keyTypeResolution = + final var keyTypeResolution = resolveType( sourceDocument, anyMapping.getKeySource().getTypeSource() ); if ( keyTypeResolution != null ) { anyBinding.setIdentifierType( keyTypeResolution.typeName ); } - final TypeResolution discriminatorTypeResolution = + final var discriminatorTypeResolution = resolveType( sourceDocument, anyMapping.getDiscriminatorSource().getTypeSource() ); final String discriminatorTypeName; @@ -2111,7 +2110,7 @@ private BasicType resolveExplicitlyNamedAnyDiscriminatorType( return (BasicType) typeInstance; } catch (ClassLoadingException e) { - CORE_LOGGER.debugf( "Unable to load explicit any-discriminator type name as Java Class - %s", typeName ); + BOOT_LOGGER.unableToLoadExplicitAnyDiscriminatorType( typeName ); } throw new org.hibernate.MappingException( @@ -2195,7 +2194,7 @@ private void bindProperty( property.setOptimisticLocked( propertySource.isIncludedInOptimisticLocking() ); if ( propertySource.isSingular() ) { - final SingularAttributeSource singularAttributeSource = (SingularAttributeSource) propertySource; + final var singularAttributeSource = (SingularAttributeSource) propertySource; property.setInsertable( singularAttributeSource.isInsertable() ); property.setUpdatable( singularAttributeSource.isUpdatable() ); // NOTE: Property#is refers to whether a property is lazy via bytecode enhancement (not proxies) @@ -2205,8 +2204,8 @@ private void bindProperty( property.setMetaAttributes( propertySource.getToolingHintContext().getMetaAttributeMap() ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.trace( "Mapped property: " + propertySource.getName() + " -> [" + columns( property.getValue() ) + "]" ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.trace( "Mapped property: " + propertySource.getName() + " -> [" + columns( property.getValue() ) + "]" ); } } @@ -2250,7 +2249,7 @@ private static void handleGenerationTiming( // generated properties can *never* be insertable... if ( property.isInsertable() && timing.includesInsert() ) { - CORE_LOGGER.tracef( + BOOT_LOGGER.tracef( "Property [%s] specified %s generation, setting insertable to false: %s", propertySource.getName(), timing.name(), @@ -2261,7 +2260,7 @@ private static void handleGenerationTiming( // properties generated on update can never be updatable... if ( property.isUpdatable() && timing.includesUpdate() ) { - CORE_LOGGER.tracef( + BOOT_LOGGER.tracef( "Property [%s] specified ALWAYS generation, setting updateable to false: %s", propertySource.getName(), mappingDocument.getOrigin() @@ -2319,28 +2318,28 @@ private void bindComponent( // todo : better define the conditions in this if/else if ( isDynamic ) { // dynamic is represented as a Map - CORE_LOGGER.tracef( "Binding dynamic component [%s]", role ); + BOOT_LOGGER.bindingDynamicComponent( role ); componentBinding.setDynamic( true ); } else if ( isVirtual ) { // virtual (what used to be called embedded) is just a conceptual composition... // for example if ( componentBinding.getOwner().hasPojoRepresentation() ) { - CORE_LOGGER.tracef( "Binding virtual component [%s] to owner class [%s]", role, componentBinding.getOwner().getClassName() ); + BOOT_LOGGER.bindingVirtualComponentToOwner( role, componentBinding.getOwner().getClassName() ); componentBinding.setComponentClassName( componentBinding.getOwner().getClassName() ); } else { - CORE_LOGGER.tracef( "Binding virtual component [%s] as dynamic", role ); + BOOT_LOGGER.bindingVirtualComponentAsDynamic( role ); componentBinding.setDynamic( true ); } } else { - CORE_LOGGER.tracef( "Binding component [%s]", role ); + BOOT_LOGGER.bindingComponent( role ); if ( isNotEmpty( explicitComponentClassName ) ) { try { final Class componentClass = sourceDocument.getBootstrapContext().getClassLoaderAccess() - .classForName( explicitComponentClassName ); + .classForName( explicitComponentClassName ); if ( CompositeUserType.class.isAssignableFrom( componentClass ) ) { @SuppressWarnings("unchecked") // Safe, we just chacked final var compositeTypeClass = @@ -2353,24 +2352,19 @@ else if ( isVirtual ) { } } catch (ClassLoadingException ex) { - CORE_LOGGER.debugf( ex, "Could load component class [%s]", explicitComponentClassName ); + BOOT_LOGGER.couldLoadComponentClass( explicitComponentClassName, ex ); } - CORE_LOGGER.tracef( "Binding component [%s] to explicitly specified class", role, explicitComponentClassName ); + BOOT_LOGGER.bindingComponentToExplicitClass( role, explicitComponentClassName ); componentBinding.setComponentClassName( explicitComponentClassName ); } else if ( componentBinding.getOwner().hasPojoRepresentation() ) { - CORE_LOGGER.tracef( "Attempting to determine component class by reflection %s", role ); - final Class reflectedComponentClass = + BOOT_LOGGER.attemptingToDetermineComponentClassByReflection( role ); + final var reflectedComponentClass = isNotEmpty( containingClassName ) && isNotEmpty( propertyName ) ? reflectedPropertyClass( sourceDocument, containingClassName, propertyName ) : null; - if ( reflectedComponentClass == null ) { - CORE_LOGGER.debugf( - "Unable to determine component class name via reflection, and explicit " + - "class name not given; role=[%s]", - role - ); + BOOT_LOGGER.unableToDetermineComponentClassByReflection( role ); } else { componentBinding.setComponentClassName( reflectedComponentClass.getName() ); @@ -2391,7 +2385,7 @@ else if ( componentBinding.getOwner().hasPojoRepresentation() ) { if ( embeddableSource.isUnique() ) { final ArrayList cols = new ArrayList<>(); - for ( Selectable selectable: componentBinding.getSelectables() ) { + for ( var selectable: componentBinding.getSelectables() ) { if ( selectable instanceof Column column ) { cols.add( column ); } @@ -2415,9 +2409,8 @@ private void bindAllCompositeAttributes( EmbeddableSource embeddableSource, Component component) { - for ( AttributeSource attributeSource : embeddableSource.attributeSources() ) { + for ( var attributeSource : embeddableSource.attributeSources() ) { Property attribute; - if ( attributeSource instanceof SingularAttributeSourceBasic singularAttributeSourceBasic ) { attribute = createBasicAttribute( sourceDocument, @@ -2491,7 +2484,7 @@ private static void bindSimpleValueType( simpleValue.makeNationalized(); } - final TypeResolution typeResolution = resolveType( mappingDocument, typeSource ); + final var typeResolution = resolveType( mappingDocument, typeSource ); if ( typeResolution != null ) { if ( isNotEmpty( typeResolution.parameters ) ) { simpleValue.setTypeParameters( typeResolution.parameters ); @@ -2555,7 +2548,7 @@ private Table bindEntityTableSpecification( Table denormalizedSuperTable, final EntitySource entitySource, PersistentClass entityDescriptor) { - final Namespace namespace = database.locateNamespace( + final var namespace = database.locateNamespace( determineCatalogName( tableSpecSource ), determineSchemaName( tableSpecSource ) ); @@ -2567,7 +2560,7 @@ private Table bindEntityTableSpecification( final Identifier logicalTableName; final Table table; if ( isTable ) { - final TableSource tableSource = (TableSource) tableSpecSource; + final var tableSource = (TableSource) tableSpecSource; if ( isNotEmpty( tableSource.getExplicitTableName() ) ) { logicalTableName = database.toIdentifier( tableSource.getExplicitTableName() ); @@ -2614,7 +2607,7 @@ public MetadataBuildingContext getBuildingContext() { } } else { - final InLineViewSource inLineViewSource = (InLineViewSource) tableSpecSource; + final var inLineViewSource = (InLineViewSource) tableSpecSource; subselect = inLineViewSource.getSelectStatement(); logicalTableName = database.toIdentifier( inLineViewSource.getLogicalName() ); if ( denormalizedSuperTable == null ) { @@ -2662,9 +2655,9 @@ private static EntityTableXref superEntityTableXref( PersistentClass entityDescriptor, InFlightMetadataCollector metadataCollector) { if ( entitySource.getSuperType() != null ) { - final EntitySource supertype = (EntitySource) entitySource.getSuperType(); + final var supertype = (EntitySource) entitySource.getSuperType(); final String superEntityName = supertype.getEntityNamingSource().getEntityName(); - final EntityTableXref superEntityTableXref = metadataCollector.getEntityTableXref( superEntityName ); + final var superEntityTableXref = metadataCollector.getEntityTableXref( superEntityName ); if ( superEntityTableXref == null ) { throw new MappingException( String.format( @@ -2781,7 +2774,7 @@ public DelayedPropertyReferenceHandlerImpl( } public void process(InFlightMetadataCollector metadataCollector) { - CORE_LOGGER.tracef( + BOOT_LOGGER.tracef( "Performing delayed property-ref handling [%s, %s, %s]", referencedEntityName, referencedPropertyName, @@ -2860,19 +2853,23 @@ public void doSecondPass(Map persistentClasses) { collectionBinding.createAllKeys(); - if ( CORE_LOGGER.isTraceEnabled() ) { - final Collection collectionBinding = getCollectionBinding(); - CORE_LOGGER.tracef( "Mapped collection: %s", getPluralAttributeSource().getAttributeRole().getFullPath() ); - CORE_LOGGER.tracef( " + table -> %s", collectionBinding.getTable().getName() ); - CORE_LOGGER.tracef( " + key -> %s", columns( collectionBinding.getKey() ) ); - if ( collectionBinding.isIndexed() ) { - CORE_LOGGER.tracef( " + index -> %s", columns( ( (IndexedCollection) collectionBinding).getIndex() ) ); + if ( BOOT_LOGGER.isTraceEnabled() ) { + final var collection = getCollectionBinding(); + BOOT_LOGGER.tracef( "Mapped collection: %s", + getPluralAttributeSource().getAttributeRole().getFullPath() ); + BOOT_LOGGER.tracef( " + table -> %s", collection.getTable().getName() ); + BOOT_LOGGER.tracef( " + key -> %s", columns( collection.getKey() ) ); + if ( collection.isIndexed() ) { + BOOT_LOGGER.tracef( " + index -> %s", + columns( ( (IndexedCollection) collection).getIndex() ) ); } - if ( collectionBinding.isOneToMany() ) { - CORE_LOGGER.tracef( " + one-to-many -> %s", ( (OneToMany) collectionBinding.getElement() ).getReferencedEntityName() ); + if ( collection.isOneToMany() ) { + BOOT_LOGGER.tracef( " + one-to-many -> %s", + ( (OneToMany) collection.getElement() ).getReferencedEntityName() ); } else { - CORE_LOGGER.tracef( " + element -> %s", columns( collectionBinding.getElement() ) ); + BOOT_LOGGER.tracef( " + element -> %s", + columns( collection.getElement() ) ); } } } @@ -2898,7 +2895,7 @@ private void bindCollectionTable() { final var tableSpecSource = pluralAttributeSource.getCollectionTableSpecificationSource(); final Identifier logicalCatalogName = determineCatalogName( tableSpecSource ); final Identifier logicalSchemaName = determineSchemaName( tableSpecSource ); - final Namespace namespace = database.locateNamespace( logicalCatalogName, logicalSchemaName ); + final var namespace = database.locateNamespace( logicalCatalogName, logicalSchemaName ); final Table collectionTable; if ( tableSpecSource instanceof TableSource tableSource ) { @@ -2925,10 +2922,10 @@ private void bindCollectionTable() { } - final Table collectionTable = collectionBinding.getCollectionTable(); + final var collectionTable = collectionBinding.getCollectionTable(); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( "Mapping collection: %s -> %s", + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.mappingCollectionToTable( collectionBinding.getRole(), collectionTable.getName() ); } @@ -2947,8 +2944,8 @@ private Identifier logicalName(TableSource tableSource) { mappingDocument.getEffectiveDefaults().isDefaultQuoteIdentifiers() ); } else { - final PersistentClass owner = collectionBinding.getOwner(); - final EntityNaming ownerEntityNaming = new EntityNamingSourceImpl( + final var owner = collectionBinding.getOwner(); + final var ownerEntityNaming = new EntityNamingSourceImpl( owner.getEntityName(), owner.getClassName(), owner.getJpaEntityName() @@ -2985,10 +2982,10 @@ protected void createBackReferences() { && !collectionBinding.isInverse() && !collectionBinding.getKey().isNullable() ) { // for non-inverse one-to-many, with a not-null fk, add a backref! - final OneToMany oneToMany = (OneToMany) collectionBinding.getElement(); + final var oneToMany = (OneToMany) collectionBinding.getElement(); final String entityName = oneToMany.getReferencedEntityName(); - final PersistentClass referenced = getReferencedEntityBinding( entityName ); - final Backref backref = new Backref(); + final var referenced = getReferencedEntityBinding( entityName ); + final var backref = new Backref(); backref.setName( '_' + collectionBinding.getOwnerEntityName() + "." + pluralAttributeSource.getName() + "Backref" ); backref.setOptional( true ); backref.setUpdatable( false ); @@ -2998,8 +2995,8 @@ protected void createBackReferences() { backref.setValue( collectionBinding.getKey() ); referenced.addProperty( backref ); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.tracef( "Added virtual backref property [%s] : %s", backref.getName(), pluralAttributeSource.getAttributeRole().getFullPath() @@ -3009,17 +3006,17 @@ protected void createBackReferences() { } protected void bindCollectionKey() { - final PluralAttributeSource pluralAttributeSource = getPluralAttributeSource(); - final PluralAttributeKeySource keySource = pluralAttributeSource.getKeySource(); + final var pluralAttributeSource = getPluralAttributeSource(); + final var keySource = pluralAttributeSource.getKeySource(); final String referencedPropertyName = keySource.getReferencedPropertyName(); - final Collection collectionBinding = getCollectionBinding(); + final var collectionBinding = getCollectionBinding(); collectionBinding.setReferencedPropertyName( referencedPropertyName ); - final PersistentClass owner = collectionBinding.getOwner(); - final KeyValue keyVal = referencedPropertyName == null + final var owner = collectionBinding.getOwner(); + final var keyVal = referencedPropertyName == null ? owner.getIdentifier() : (KeyValue) owner.getRecursiveProperty( referencedPropertyName ).getValue(); - final DependantValue key = new DependantValue( + final var key = new DependantValue( mappingDocument, collectionBinding.getCollectionTable(), keyVal @@ -3056,8 +3053,8 @@ protected void bindCollectionKey() { protected void bindCollectionIdentifier() { final CollectionIdSource idSource = getPluralAttributeSource().getCollectionIdSource(); if ( idSource != null ) { - final IdentifierCollection idBagBinding = (IdentifierCollection) getCollectionBinding(); - final BasicValue idBinding = new BasicValue( + final var idBagBinding = (IdentifierCollection) getCollectionBinding(); + final var idBinding = new BasicValue( mappingDocument, idBagBinding.getCollectionTable() ); @@ -3092,17 +3089,17 @@ protected void bindCollectionIndex() { protected void bindCollectionElement() { final PluralAttributeElementSource pluralElementSource = getPluralAttributeSource().getElementSource(); - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.tracef( "Binding [%s] element type for a [%s]", pluralElementSource.getNature(), getPluralAttributeSource().getNature() ); } - final Collection collectionBinding = getCollectionBinding(); - final MappingDocument mappingDocument = getMappingDocument(); + final var collectionBinding = getCollectionBinding(); + final var mappingDocument = getMappingDocument(); if ( pluralElementSource instanceof PluralAttributeElementSourceBasic elementSource ) { - final BasicValue elementBinding = + final var elementBinding = new BasicValue( mappingDocument, collectionBinding.getCollectionTable() ); bindSimpleValueType( @@ -3127,9 +3124,9 @@ protected void bindCollectionElement() { collectionBinding.setWhere( getPluralAttributeSource().getWhere() ); } else if ( pluralElementSource instanceof PluralAttributeElementSourceEmbedded elementSource ) { - final Component elementBinding = new Component( mappingDocument, collectionBinding ); + final var elementBinding = new Component( mappingDocument, collectionBinding ); - final EmbeddableSource embeddableSource = elementSource.getEmbeddableSource(); + final var embeddableSource = elementSource.getEmbeddableSource(); bindComponent( this.mappingDocument, embeddableSource, @@ -3146,11 +3143,11 @@ else if ( pluralElementSource instanceof PluralAttributeElementSourceEmbedded el collectionBinding.setWhere( getPluralAttributeSource().getWhere() ); } else if ( pluralElementSource instanceof PluralAttributeElementSourceOneToMany elementSource ) { - final OneToMany elementBinding = + final var elementBinding = new OneToMany( mappingDocument, collectionBinding.getOwner() ); this.collectionBinding.setElement( elementBinding ); - final PersistentClass referencedEntityBinding = + final var referencedEntityBinding = getReferencedEntityBinding( elementSource.getReferencedEntityName() ); this.collectionBinding.setWhere( @@ -3234,8 +3231,8 @@ else if ( pluralElementSource instanceof PluralAttributeElementSourceManyToMany for ( FilterSource filterSource : elementSource.getFilterSources() ) { if ( filterSource.getName() == null ) { - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.tracef( "Encountered filter with no name associated with many-to-many [%s]; skipping", getPluralAttributeSource().getAttributeRole().getFullPath() ); @@ -3255,8 +3252,8 @@ else if ( pluralElementSource instanceof PluralAttributeElementSourceManyToMany ); } - if ( CORE_LOGGER.isTraceEnabled() ) { - CORE_LOGGER.tracef( + if ( BOOT_LOGGER.isTraceEnabled() ) { + BOOT_LOGGER.tracef( "Applying many-to-many filter [%s] as [%s] to collection [%s]", filterSource.getName(), filterSource.getCondition(), @@ -3388,7 +3385,7 @@ protected void createBackReferences() { final var collectionBinding = getCollectionBinding(); boolean indexIsFormula = false; - for ( Selectable selectable: collectionBinding.getIndex().getSelectables() ) { + for ( var selectable: collectionBinding.getIndex().getSelectables() ) { if ( selectable.isFormula() ) { indexIsFormula = true; break; @@ -3399,10 +3396,10 @@ protected void createBackReferences() { && !collectionBinding.getKey().isNullable() && !collectionBinding.isInverse() && !indexIsFormula ) { - final OneToMany oneToMany = (OneToMany) collectionBinding.getElement(); + final var oneToMany = (OneToMany) collectionBinding.getElement(); final String entityName = oneToMany.getReferencedEntityName(); - final PersistentClass referenced = getMappingDocument().getMetadataCollector().getEntityBinding( entityName ); - final IndexBackref backref = new IndexBackref(); + final var referenced = getMappingDocument().getMetadataCollector().getEntityBinding( entityName ); + final var backref = new IndexBackref(); backref.setName( '_' + collectionBinding.getOwnerEntityName() + "." + getPluralAttributeSource().getName() + "IndexBackref" ); backref.setOptional( true ); backref.setUpdatable( false ); @@ -3478,10 +3475,10 @@ private void createIndexBackRef( if ( collectionBinding.isOneToMany() && !collectionBinding.getKey().isNullable() && !collectionBinding.isInverse() ) { - OneToMany oneToMany = (OneToMany) collectionBinding.getElement(); + final var oneToMany = (OneToMany) collectionBinding.getElement(); final String entityName = oneToMany.getReferencedEntityName(); - final PersistentClass referenced = mappingDocument.getMetadataCollector().getEntityBinding( entityName ); - final IndexBackref backref = new IndexBackref(); + final var referenced = mappingDocument.getMetadataCollector().getEntityBinding( entityName ); + final var backref = new IndexBackref(); backref.setName( '_' + collectionBinding.getOwnerEntityName() + "." + pluralAttributeSource.getName() + "IndexBackref" ); backref.setOptional( true ); backref.setUpdatable( false ); @@ -3536,10 +3533,10 @@ public void bindListOrArrayIndex( MappingDocument mappingDocument, final IndexedPluralAttributeSource attributeSource, org.hibernate.mapping.List collectionBinding) { - final PluralAttributeSequentialIndexSource indexSource = + final var indexSource = (PluralAttributeSequentialIndexSource) attributeSource.getIndexSource(); - final BasicValue indexBinding = new BasicValue( mappingDocument, collectionBinding.getCollectionTable() ); + final var indexBinding = new BasicValue( mappingDocument, collectionBinding.getCollectionTable() ); bindSimpleValueType( mappingDocument, indexSource.getTypeInformation(), indexBinding ); relationalObjectBinder.bindColumnsAndFormulas( @@ -3572,7 +3569,7 @@ private void bindMapKey( final org.hibernate.mapping.Map collectionBinding) { final PluralAttributeIndexSource indexSource = pluralAttributeSource.getIndexSource(); if ( indexSource instanceof PluralAttributeMapKeySourceBasic mapKeySource ) { - final BasicValue value = new BasicValue( mappingDocument, collectionBinding.getCollectionTable() ); + final var value = new BasicValue( mappingDocument, collectionBinding.getCollectionTable() ); bindSimpleValueType( mappingDocument, mapKeySource.getTypeInformation(), value ); if ( !value.isTypeSpecified() ) { throw new MappingException( @@ -3593,7 +3590,7 @@ private void bindMapKey( collectionBinding.setIndex( value ); } else if ( indexSource instanceof PluralAttributeMapKeySourceEmbedded mapKeySource ) { - final Component componentBinding = new Component( mappingDocument, collectionBinding ); + final var componentBinding = new Component( mappingDocument, collectionBinding ); bindComponent( mappingDocument, mapKeySource.getEmbeddableSource(), @@ -3605,7 +3602,7 @@ else if ( indexSource instanceof PluralAttributeMapKeySourceEmbedded mapKeySourc collectionBinding.setIndex( componentBinding ); } else if ( indexSource instanceof PluralAttributeMapKeyManyToManySource mapKeySource ) { - final ManyToOne mapKeyBinding = new ManyToOne( mappingDocument, collectionBinding.getCollectionTable() ); + final var mapKeyBinding = new ManyToOne( mappingDocument, collectionBinding.getCollectionTable() ); mapKeyBinding.setReferencedEntityName( mapKeySource.getReferencedEntityName() ); @@ -3631,7 +3628,7 @@ public MetadataBuildingContext getBuildingContext() { collectionBinding.setIndex( mapKeyBinding ); } else if ( indexSource instanceof PluralAttributeMapKeyManyToAnySource mapKeySource) { - final Any mapKeyBinding = new Any( mappingDocument, collectionBinding.getCollectionTable() ); + final var mapKeyBinding = new Any( mappingDocument, collectionBinding.getCollectionTable() ); bindAny( mappingDocument, mapKeySource, mapKeyBinding, pluralAttributeSource.getAttributeRole().append( "key" ) ); collectionBinding.setIndex( mapKeyBinding ); @@ -3674,7 +3671,7 @@ public boolean canProcessImmediately() { return true; } - final PersistentClass referencedEntityBinding = + final var referencedEntityBinding = mappingDocument.getMetadataCollector().getEntityBinding( referencedEntityName ); if ( referencedEntityBinding == null ) { return false; @@ -3706,7 +3703,7 @@ public void doSecondPass(Map persistentClasses) { // implicit naming. If we get here, we assume that there is only a single // column making up the FK. - final PersistentClass referencedEntityBinding = + final var referencedEntityBinding = mappingDocument.getMetadataCollector().getEntityBinding( referencedEntityName ); if ( referencedEntityBinding == null ) { @@ -3851,12 +3848,12 @@ public void addAttributeBinding(Property attributeBinding) { @Override public void process() { - CORE_LOGGER.tracef( "Binding natural-id UniqueKey for entity: %s", entityBinding.getEntityName() ); + BOOT_LOGGER.bindingNaturalIdUniqueKey( entityBinding.getEntityName() ); final List columnNames = new ArrayList<>(); - final UniqueKey uniqueKey = new UniqueKey( entityBinding.getTable() ); - for ( Property attributeBinding : attributeBindings ) { + final var uniqueKey = new UniqueKey( entityBinding.getTable() ); + for ( var attributeBinding : attributeBindings ) { for ( Selectable selectable : attributeBinding.getSelectables() ) { if ( selectable instanceof Column column ) { uniqueKey.addColumn( column ); @@ -3866,7 +3863,7 @@ public void process() { uniqueKey.addColumns( attributeBinding.getValue() ); } - final Identifier uniqueKeyName = mappingDocument.getBuildingOptions().getImplicitNamingStrategy() + final var uniqueKeyName = mappingDocument.getBuildingOptions().getImplicitNamingStrategy() .determineUniqueKeyName( new ImplicitUniqueKeyNameSource() { @Override @@ -3898,8 +3895,8 @@ public Identifier getUserProvidedIdentifier() { } private String columns(Value value) { - final StringBuilder builder = new StringBuilder(); - for ( Selectable selectable : value.getSelectables() ) { + final var builder = new StringBuilder(); + for ( var selectable : value.getSelectables() ) { if ( !builder.isEmpty() ) { builder.append( ", " ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/internal/GlobalRegistrationsImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/models/internal/GlobalRegistrationsImpl.java index 4d079cd5417e..8d7f51ef28e9 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/models/internal/GlobalRegistrationsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/models/internal/GlobalRegistrationsImpl.java @@ -111,7 +111,7 @@ import static org.hibernate.boot.models.JpaAnnotations.TABLE_GENERATOR; import static org.hibernate.boot.models.HibernateAnnotations.TYPE_REGISTRATION; import static org.hibernate.boot.models.xml.internal.QueryProcessing.collectResultClasses; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.internal.util.StringHelper.isNotEmpty; import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty; @@ -860,7 +860,7 @@ private void checkGeneratorName(String name, Map generatorMap) { throw new IllegalArgumentException( "Duplicate generator name " + name + "; you will likely want to set the property " + AvailableSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE + " to false " ); } else { - CORE_LOGGER.duplicateGeneratorName( name ); + BOOT_LOGGER.duplicateGeneratorName( name ); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java index 027ba6837412..bd9fdb6b6153 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java @@ -21,7 +21,7 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; /** * Standard implementation of the service for interacting with class loaders @@ -131,7 +131,7 @@ public URL locateResource(String name) { public InputStream locateResourceStream(String name) { // first we try name as a URL try { - CORE_LOGGER.tracef( "trying via [new URL(\"%s\")]", name ); + BOOT_LOGGER.tryingURL( name ); return new URL( name ).openStream(); } catch (Exception ignore) { @@ -142,7 +142,7 @@ public InputStream locateResourceStream(String name) { name = stripClasspathScheme( name ); try { - CORE_LOGGER.tracef( "trying via [ClassLoader.getResourceAsStream(\"%s\")]", name ); + BOOT_LOGGER.tryingClassLoader( name ); final InputStream stream = getAggregatedClassLoader().getResourceAsStream( name ); if ( stream != null ) { return stream; @@ -155,14 +155,14 @@ public InputStream locateResourceStream(String name) { if ( stripped != null ) { try { - CORE_LOGGER.tracef( "trying via [new URL(\"%s\")]", stripped ); + BOOT_LOGGER.tryingURL( stripped ); return new URL( stripped ).openStream(); } catch (Exception ignore) { } try { - CORE_LOGGER.tracef( "trying via [ClassLoader.getResourceAsStream(\"%s\")]", stripped ); + BOOT_LOGGER.tryingClassLoader( stripped ); final InputStream stream = getAggregatedClassLoader().getResourceAsStream( stripped ); if ( stream != null ) { return stream; @@ -220,11 +220,11 @@ public Package packageForNameOrNull(String packageName) { .getPackage(); } catch (ClassNotFoundException e) { - CORE_LOGGER.packageNotFound( packageName ); + BOOT_LOGGER.packageNotFound( packageName ); return null; } catch (LinkageError e) { - CORE_LOGGER.linkageError( packageName, e ); + BOOT_LOGGER.linkageError( packageName, e ); return null; } } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java index 30bce0244b51..de9337266fbf 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -4,8 +4,6 @@ */ package org.hibernate.internal; -import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.lang.invoke.MethodHandles; import java.sql.SQLException; @@ -16,7 +14,6 @@ import org.hibernate.Internal; import org.hibernate.cache.CacheException; import org.hibernate.internal.log.SubSystemLogging; -import org.hibernate.type.SerializationException; import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; @@ -50,10 +47,6 @@ public interface CoreMessageLogger extends BasicLogger { Logger LOGGER = Logger.getLogger( NAME ); CoreMessageLogger CORE_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), CoreMessageLogger.class, NAME ); - @LogMessage(level = WARN) - @Message(value = "I/O reported cached file could not be found: [%s]: %s", id = 23) - void cachedFileNotFound(String path, FileNotFoundException error); - @LogMessage(level = WARN) @Message(value = "Composite id class does not override equals(): %s", id = 38) void compositeIdClassDoesNotOverrideEquals(String name); @@ -70,10 +63,6 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "Defining %s=true ignored in HEM", id = 59) void definingFlushBeforeCompletionIgnoredInHem(String flushBeforeCompletion); - @LogMessage(level = WARN) - @Message(value = "Duplicate generator name %s", id = 69) - void duplicateGeneratorName(String name); - @LogMessage(level = WARN) @Message(value = "Entity [%s] is abstract-class/interface explicitly mapped as non-abstract; be sure to supply entity-names", id = 84) @@ -97,10 +86,6 @@ void expectedType(String name, @Message(value = "HSQLDB supports only READ_UNCOMMITTED isolation", id = 118) void hsqldbSupportsOnlyReadCommittedIsolation(); - @LogMessage(level = WARN) - @Message(value = "Ignoring unique constraints specified on table generator [%s]", id = 120) - void ignoringTableGeneratorConstraints(String name); - @LogMessage(level = ERROR) @Message(value = "IllegalArgumentException in class: %s, getter method of property: %s", id = 122) void illegalPropertyGetterArgument(String name, String propertyName); @@ -136,14 +121,6 @@ void missingArguments( @Message(value = "Overriding %s is dangerous, this might break the EJB3 specification implementation", id = 193) void overridingTransactionStrategyDangerous(String transactionStrategy); - @LogMessage(level = DEBUG) - @Message(value = "Package not found or no package-info.java: %s", id = 194) - void packageNotFound(String packageName); - - @LogMessage(level = WARN) - @Message(value = "LinkageError while attempting to load package: %s", id = 195) - void linkageError(String packageName, @Cause LinkageError e); - @LogMessage(level = INFO) @Message(value = "Processing PersistenceUnitInfo [name: %s]", id = 204) void processingPersistenceUnitInfoName(String persistenceUnitName); @@ -156,14 +133,6 @@ void missingArguments( @Message(value = "'hibernate.properties' not found", id = 206) void propertiesNotFound(); - @LogMessage(level = INFO) - @Message(value = "Reading mappings from cache file: %s", id = 219) - void readingCachedMappings(File cachedFile); - - @LogMessage(level = INFO) - @Message(value = "Reading mappings from file: %s", id = 220) - void readingMappingsFromFile(String path); - @LogMessage(level = WARN) @Message(value = "Recognized obsolete hibernate namespace %s. Use namespace %s instead. Refer to Hibernate 3.6 Migration Guide", id = 223) @@ -251,10 +220,6 @@ void missingArguments( @Message(value = "Error creating schema ", id = 306) void unableToCreateSchema(@Cause Exception e); - @LogMessage(level = WARN) - @Message(value = "Could not deserialize cache file [%s]: %s", id = 307) - void unableToDeserializeCache(String path, SerializationException error); - @LogMessage(level = INFO) @Message(value = "Could not find any META-INF/persistence.xml file in the classpath", id = 318) void unableToFindPersistenceXmlInClasspath(); @@ -295,10 +260,6 @@ void missingArguments( @Message(value = "Error running schema update", id = 366) void unableToRunSchemaUpdate(@Cause Exception e); - @LogMessage(level = WARN) - @Message(value = "I/O reported error writing cached file: %s: %s", id = 378) - void unableToWriteCachedFile(String path, String message); - @LogMessage(level = WARN) @Message(value = "The %s.%s.%s version of H2 implements temporary table creation such that it commits current transaction; multi-table, bulk HQL/JPQL will not work properly", id = 393) @@ -337,19 +298,6 @@ void missingArguments( ) void usingFollowOnLocking(); - @LogMessage(level = WARN) - @Message( - id = 449, - value = "@Convert annotation applied to Map attribute [%s] did not explicitly specify " - + "'attributeName=\"key\" or 'attributeName=\"value\"' as required by spec; " - + "attempting to infer whether converter applies to key or value" - ) - void nonCompliantMapConversion(String collectionRole); - - @LogMessage(level = INFO) - @Message(value = "Omitting cached file [%s] as the mapping file is newer", id = 473) - void cachedFileObsolete(File cachedFile); - @LogMessage(level = INFO) @Message(value = "Cannot locate column information using identifier [%s]; ignoring index [%s]", id = 475 ) void logCannotLocateIndexColumnInformation(String columnIdentifierText, String indexIdentifierText); @@ -392,11 +340,6 @@ void missingArguments( @Message(value = "Using JTA platform [%s]", id = 490) void usingJtaPlatform(String jtaPlatformClassName); - @LogMessage(level = WARN) - @Message(value = "'%1$s.%2$s' uses both @NotFound and FetchType.LAZY. @ManyToOne and " + - "@OneToOne associations mapped with @NotFound are forced to EAGER fetching.", id = 491) - void ignoreNotFoundWithFetchTypeLazy(String entity, String association); - @LogMessage(level = WARN) @Message(value = "Attempt to merge an uninitialized collection with queued operations; queued operations will be ignored: %s", id = 494) void ignoreQueuedOperationsOnMerge(String collectionInfoString); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaManyToOneNotIgnoreLazyFetchingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaManyToOneNotIgnoreLazyFetchingTest.java index 179379c83f92..8ecc8c168778 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaManyToOneNotIgnoreLazyFetchingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaManyToOneNotIgnoreLazyFetchingTest.java @@ -31,7 +31,7 @@ import jakarta.persistence.ManyToOne; import static org.assertj.core.api.Assertions.assertThat; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -41,9 +41,9 @@ public class JoinFormulaManyToOneNotIgnoreLazyFetchingTest extends BaseEntityManagerFunctionalTestCase { @Rule - public LoggerInspectionRule logInspection = new LoggerInspectionRule( CORE_LOGGER ); + public LoggerInspectionRule logInspection = new LoggerInspectionRule( BOOT_LOGGER ); - private final Triggerable triggerable = logInspection.watchForLogMessages( "HHH000491" ); + private final Triggerable triggerable = logInspection.watchForLogMessages( "HHH160133" ); @Override diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaOneToOneNotIgnoreLazyFetchingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaOneToOneNotIgnoreLazyFetchingTest.java index 455975ff4362..44759e871928 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaOneToOneNotIgnoreLazyFetchingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaOneToOneNotIgnoreLazyFetchingTest.java @@ -31,7 +31,7 @@ import jakarta.persistence.OneToOne; import static org.assertj.core.api.Assertions.assertThat; -import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER; +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -41,9 +41,9 @@ public class JoinFormulaOneToOneNotIgnoreLazyFetchingTest extends BaseEntityManagerFunctionalTestCase { @Rule - public LoggerInspectionRule logInspection = new LoggerInspectionRule( CORE_LOGGER ); + public LoggerInspectionRule logInspection = new LoggerInspectionRule( BOOT_LOGGER ); - private final Triggerable triggerable = logInspection.watchForLogMessages( "HHH000491" ); + private final Triggerable triggerable = logInspection.watchForLogMessages( "HHH160133" ); @Override