diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DialectLogging.java b/hibernate-core/src/main/java/org/hibernate/dialect/DialectLogging.java new file mode 100644 index 0000000000..e630cacfcc --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DialectLogging.java @@ -0,0 +1,39 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.dialect; + +import org.hibernate.internal.log.SubSystemLogging; + +import org.jboss.logging.Logger; +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.INFO; + +/** + * Logging related to Hibernate dialects + */ +@SubSystemLogging( + name = DialectLogging.LOGGER_NAME, + description = "Logging related to the dialects of SQL implemented by particular RDBMS" +) +@ValidIdRange( min = 35001, max = 36000) +@MessageLogger(projectCode = "HHH") +public interface DialectLogging { + String LOGGER_NAME = SubSystemLogging.BASE + ".dialect"; + Logger DIALECT_LOGGER = Logger.getLogger(LOGGER_NAME); + DialectLogging DIALECT_MESSAGE_LOGGER = Logger.getMessageLogger(DialectLogging.class, LOGGER_NAME); + + boolean DEBUG_ENABLED = DIALECT_LOGGER.isDebugEnabled(); + boolean TRACE_ENABLED = DIALECT_LOGGER.isTraceEnabled(); + + @LogMessage(level = INFO) + @Message(value = "Using dialect: %s", id = 35001) + void usingDialect(Dialect dialect); +} diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java index 9d24e337a2..3eae23ebe2 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java @@ -15,12 +15,11 @@ import org.hibernate.boot.registry.selector.spi.StrategySelectionException; import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.cfg.AvailableSettings; import org.hibernate.dialect.Dialect; +import org.hibernate.dialect.DialectLogging; import org.hibernate.engine.jdbc.dialect.spi.DialectFactory; import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo; import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource; import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; -import org.hibernate.internal.CoreLogging; -import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; import org.hibernate.service.spi.ServiceRegistryAwareService; import org.hibernate.service.spi.ServiceRegistryImplementor; @@ -33,7 +32,6 @@ import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER; * @author Steve Ebersole */ public class DialectFactoryImpl implements DialectFactory, ServiceRegistryAwareService { - private static final CoreMessageLogger LOG = CoreLogging.messageLogger( "SQL dialect" ); private static final Set LEGACY_DIALECTS = Set.of( "org.hibernate.community.dialect.DB297Dialect", "org.hibernate.community.dialect.DB2390Dialect", @@ -92,7 +90,7 @@ public class DialectFactoryImpl implements DialectFactory, ServiceRegistryAwareS } private static void logSelectedDialect(Dialect dialect) { - LOG.usingDialect( dialect ); + DialectLogging.DIALECT_MESSAGE_LOGGER.usingDialect( dialect ); Class dialectClass = dialect.getClass(); if ( dialectClass.isAnnotationPresent( Deprecated.class ) ) { 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 0e5810a2b3..9c15babe7a 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -1359,8 +1359,12 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "Using default transaction strategy (direct JDBC transactions)", id = 399) void usingDefaultTransactionStrategy(); + /** + * @deprecated Use {@link org.hibernate.dialect.DialectLogging#usingDialect} instead + */ @LogMessage(level = INFO) @Message(value = "Using dialect: %s", id = 400) + @Deprecated void usingDialect(Dialect dialect); @LogMessage(level = ERROR)