diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java index c808ded97e..4a0ff04545 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java @@ -48,7 +48,12 @@ public JtaPlatform initiateService(Map configurationValues, Serv platform = getFallbackProvider( configurationValues, registry ); } - LOG.usingJtaPlatform( platform != null ? platform.getClass().getName() : "null" ); + if ( platform != null && !(platform instanceof NoJtaPlatform) ) { + LOG.usingJtaPlatform( platform.getClass().getName() ); + } + else { + LOG.noJtaPlatform(); + } return platform; } 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 44a96e27a9..e54202b8c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -81,7 +81,7 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "On release of batch it still contained JDBC statements", id = 10) void batchContainedStatementsOnRelease(); - @LogMessage(level = INFO) + @LogMessage(level = DEBUG) @Message(value = "Bytecode provider: %s", id = 21) void bytecodeProvider(String provider); @@ -91,7 +91,7 @@ public interface CoreMessageLogger extends BasicLogger { void c3p0ProviderClassNotFound(String c3p0ProviderClassName); @LogMessage(level = WARN) - @Message(value = "I/O reported cached file could not be found : %s : %s", id = 23) + @Message(value = "I/O reported cached file could not be found: [%s]: %s", id = 23) void cachedFileNotFound(String path, FileNotFoundException error); @LogMessage(level = INFO) @@ -187,7 +187,7 @@ public interface CoreMessageLogger extends BasicLogger { // void deprecatedForceDescriminatorAnnotation(); @LogMessage(level = WARN) - @Message(value = "DEPRECATED : use [%s] instead with custom [%s] implementation", id = 65) + @Message(value = "DEPRECATED: use [%s] instead with custom [%s] implementation", id = 65) void deprecatedUuidGenerator(String name, String name2); @LogMessage(level = INFO) @@ -264,7 +264,7 @@ public interface CoreMessageLogger extends BasicLogger { void exceptionInBeforeTransactionCompletionInterceptor(@Cause Throwable e); @LogMessage(level = INFO) - @Message(value = "Sub-resolver threw unexpected exception, continuing to next : %s", id = 89) + @Message(value = "Sub-resolver threw unexpected exception, continuing to next: %s", id = 89) void exceptionInSubResolver(String message); @LogMessage(level = ERROR) @@ -563,7 +563,7 @@ void noSessionFactoryWithJndiName( // void parameterPositionOccurredAsBothJpaAndHibernatePositionalParameter(Integer position); @LogMessage(level = ERROR) - @Message(value = "Error parsing XML (%s) : %s", id = 196) + @Message(value = "Error parsing XML: (%s) %s", id = 196) void parsingXmlError( int lineNumber, String message); @@ -576,7 +576,7 @@ void parsingXmlErrorForFile( String message); @LogMessage(level = ERROR) - @Message(value = "Warning parsing XML (%s) : %s", id = 198) + @Message(value = "Warning parsing XML: (%s) %s", id = 198) void parsingXmlWarning( int lineNumber, String message); @@ -615,11 +615,11 @@ void parsingXmlWarningForFile( void propertiesLoaded(Properties maskOut); @LogMessage(level = DEBUG) - @Message(value = "hibernate.properties not found", id = 206) + @Message(value = "'hibernate.properties' not found", id = 206) void propertiesNotFound(); @LogMessage(level = WARN) - @Message(value = "Property %s not found in class but described in (possible typo error)", id = 207) + @Message(value = "Property '%s' not found in class but described in (possible typo error)", id = 207) void propertyNotFound(String property); // @LogMessage(level = WARN) @@ -793,7 +793,7 @@ void sqlWarning( void stoppingService(); @LogMessage(level = INFO) - @Message(value = "sub-resolver threw unexpected exception, continuing to next : %s", id = 257) + @Message(value = "sub-resolver threw unexpected exception, continuing to next: %s", id = 257) void subResolverException(String message); @LogMessage(level = INFO) @@ -805,7 +805,7 @@ void sqlWarning( void synchronizationAlreadyRegistered(Synchronization synchronization); @LogMessage(level = ERROR) - @Message(value = "Exception calling user Synchronization [%s] : %s", id = 260) + @Message(value = "Exception calling user Synchronization [%s]: %s", id = 260) void synchronizationFailed( Synchronization synchronization, Throwable t); @@ -839,7 +839,7 @@ void synchronizationFailed( void typeDefinedNoRegistrationKeys(Object type); @LogMessage(level = DEBUG) - @Message(value = "Type registration key [%s] overrode previous key : %s", id = 270) + @Message(value = "Type registration key [%s] overrode previous key: %s", id = 270) void typeRegistrationKeyOverridesPrevious( String key, Type old); @@ -855,7 +855,7 @@ void unableToAccessSessionFactory( @Cause NamingException e); @LogMessage(level = WARN) - @Message(value = "Error accessing type info result set : %s", id = 273) + @Message(value = "Error accessing type info result set: %s", id = 273) void unableToAccessTypeInfoResultSet(String string); @LogMessage(level = WARN) @@ -966,7 +966,7 @@ void unableToCloseOutputFile( void unableToCompleteSchemaValidation(@Cause SQLException e); @LogMessage(level = WARN) - @Message(value = "Unable to configure SQLExceptionConverter : %s", id = 301) + @Message(value = "Unable to configure SQLExceptionConverter: %s", id = 301) void unableToConfigureSqlExceptionConverter(HibernateException e); @LogMessage(level = ERROR) @@ -976,7 +976,7 @@ void unableToConstructCurrentSessionContext( @Cause Throwable e); @LogMessage(level = WARN) - @Message(value = "Unable to construct instance of specified SQLExceptionConverter : %s", id = 303) + @Message(value = "Unable to construct instance of specified SQLExceptionConverter: %s", id = 303) void unableToConstructSqlExceptionConverter(Throwable t); @LogMessage(level = WARN) @@ -994,7 +994,7 @@ void unableToCreateProxyFactory( void unableToCreateSchema(@Cause Exception e); @LogMessage(level = WARN) - @Message(value = "Could not deserialize cache file: %s : %s", id = 307) + @Message(value = "Could not deserialize cache file [%s]: %s", id = 307) void unableToDeserializeCache( String path, SerializationException error); @@ -1034,7 +1034,7 @@ void unableToDestroyUpdateTimestampsCache( void unableToExecuteBatch(Exception e, String sql ); @LogMessage(level = WARN) - @Message(value = "Error executing resolver [%s] : %s", id = 316) + @Message(value = "Error executing resolver [%s]: %s", id = 316) void unableToExecuteResolver( DialectResolver abstractDialectResolver, String message); @@ -1062,7 +1062,7 @@ void unableToInstantiateConfiguredSchemaNameResolver( void unableToInstantiateOptimizer(String type); @LogMessage(level = WARN) - @Message(value = "Unable to instantiate UUID generation strategy class : %s", id = 325) + @Message(value = "Unable to instantiate UUID generation strategy class: %s", id = 325) void unableToInstantiateUuidGenerationStrategy(Exception ignore); @LogMessage(level = WARN) @@ -1074,7 +1074,7 @@ void unableToInstantiateConfiguredSchemaNameResolver( void unableToLoadCommand(@Cause HibernateException e); @LogMessage(level = WARN) - @Message(value = "Unable to load/access derby driver class sysinfo to check versions : %s", id = 328) + @Message(value = "Unable to load/access derby driver class sysinfo to check versions: %s", id = 328) void unableToLoadDerbyDriver(String message); @LogMessage(level = ERROR) @@ -1095,11 +1095,11 @@ void unableToLocateConfiguredSchemaNameResolver( void unableToLocateMBeanServer(); @LogMessage(level = WARN) - @Message(value = "Unable to locate requested UUID generation strategy class : %s", id = 334) + @Message(value = "Unable to locate requested UUID generation strategy class: %s", id = 334) void unableToLocateUuidGenerationStrategy(String strategyClassName); @LogMessage(level = WARN) - @Message(value = "Unable to log SQLWarnings : %s", id = 335) + @Message(value = "Unable to log SQLWarnings: %s", id = 335) void unableToLogSqlWarnings(SQLException sqle); @LogMessage(level = WARN) @@ -1166,7 +1166,7 @@ void unableToReadColumnValueFromResultSet( void unableToReleaseBatchStatement(); @LogMessage(level = ERROR) - @Message(value = "Could not release a cache lock : %s", id = 353) + @Message(value = "Could not release a cache lock: %s", id = 353) void unableToReleaseCacheLock(CacheException ce); @LogMessage(level = INFO) @@ -1174,7 +1174,7 @@ void unableToReadColumnValueFromResultSet( void unableToReleaseContext(String message); @LogMessage(level = WARN) - @Message(value = "Unable to release created MBeanServer : %s", id = 355) + @Message(value = "Unable to release created MBeanServer: %s", id = 355) void unableToReleaseCreatedMBeanServer(String string); @LogMessage(level = INFO) @@ -1204,7 +1204,7 @@ void unableToRetrieveCache( String message); @LogMessage(level = WARN) - @Message(value = "Unable to retrieve type info result set : %s", id = 362) + @Message(value = "Unable to retrieve type info result set: %s", id = 362) void unableToRetrieveTypeInfoResultSet(String string); @LogMessage(level = INFO) @@ -1212,7 +1212,7 @@ void unableToRetrieveCache( void unableToRollbackConnection(Exception ignore); @LogMessage(level = INFO) - @Message(value = "Unable to rollback isolated transaction on error [%s] : [%s]", id = 364) + @Message(value = "Unable to rollback isolated transaction on error [%s]: [%s]", id = 364) void unableToRollbackIsolatedTransaction( Exception e, Exception ignore); @@ -1273,7 +1273,7 @@ void unableToUpdateQueryHiValue( void unableToWrapResultSet(@Cause SQLException e); @LogMessage(level = WARN) - @Message(value = "I/O reported error writing cached file : %s: %s", id = 378) + @Message(value = "I/O reported error writing cached file: %s: %s", id = 378) void unableToWriteCachedFile( String path, String message); @@ -1395,7 +1395,7 @@ void usingUuidHexGenerator( void version(String versionString); @LogMessage(level = WARN) - @Message(value = "Warnings creating temp table : %s", id = 413) + @Message(value = "Warnings creating temp table: %s", id = 413) void warningsCreatingTempTable(SQLWarning warning); @LogMessage(level = INFO) @@ -1462,7 +1462,7 @@ void resolvedSqlTypeDescriptorForDifferentSqlCode( * @see LobCreationLogging#contextualNClobCreationFailed */ @LogMessage(level = DEBUG) - @Message(value = "Disabling contextual LOB creation as createClob() method threw error : %s", id = 424) + @Message(value = "Disabling contextual LOB creation as createClob() method threw error: %s", id = 424) @Deprecated void disablingContextualLOBCreationSinceCreateClobFailed(Throwable t); @@ -1489,7 +1489,7 @@ void legacyTransactionManagerStrategy( String jtaPlatform); @LogMessage(level = WARN) - @Message(value = "Setting entity-identifier value binding where one already existed : %s.", id = 429) + @Message(value = "Setting entity-identifier value binding where one already existed: %s.", id = 429) void entityIdentifierValueBindingExists(String name); @LogMessage(level = WARN) @@ -1585,7 +1585,7 @@ void cannotResolveNonNullableTransientDependencies( void explicitSkipLockedLockCombo(); @LogMessage(level = INFO) - @Message(value = "'jakarta.persistence.validation.mode' named multiple values : %s", id = 448) + @Message(value = "'jakarta.persistence.validation.mode' named multiple values: %s", id = 448) void multipleValidationModes(String modes); @LogMessage(level = WARN) @@ -1616,7 +1616,7 @@ void cannotResolveNonNullableTransientDependencies( void unableToLoadScannedClassOrResource(@Cause Exception e); @LogMessage(level = WARN) - @Message(value = "Exception while discovering OSGi service implementations : %s", id = 453) + @Message(value = "Exception while discovering OSGi service implementations: %s", id = 453) void unableToDiscoverOsgiService(String service, @Cause Exception e); @LogMessage(level = WARN) @@ -1640,7 +1640,7 @@ void cannotResolveNonNullableTransientDependencies( void creatingPooledLoOptimizer(int incrementSize, String name); @LogMessage(level = WARN) - @Message(value = "Unable to interpret type [%s] as an AttributeConverter due to an exception : %s", id = 468) + @Message(value = "Unable to interpret type [%s] as an AttributeConverter due to an exception: %s", id = 468) void logBadHbmAttributeConverterType(String type, String exceptionMessage); @Message(value = "The ClassLoaderService can not be reused. This instance was stopped already.", id = 469) @@ -1664,7 +1664,7 @@ void cannotResolveNonNullableTransientDependencies( void cachedFileObsolete(File cachedFile); @Message( - value = "Ambiguous persistent property methods detected on %s; mark one as @Transient : [%s] and [%s]", + value = "Ambiguous persistent property methods detected on %s; mark one as @Transient: [%s] and [%s]", id = 474 ) String ambiguousPropertyMethods(String entityName, String oneMethodSig, String secondMethodSig); @@ -1674,7 +1674,7 @@ void cannotResolveNonNullableTransientDependencies( void logCannotLocateIndexColumnInformation(String columnIdentifierText, String indexIdentifierText); @LogMessage(level = INFO) - @Message(value = "Executing script '%s'", id = 476) + @Message(value = "Executing script [%s]", id = 476) void executingScript(String scriptName); @LogMessage(level = INFO) @@ -1749,7 +1749,11 @@ void attemptToAssociateProxyWithTwoOpenSessions( String bytecodeEnhancementFailedUnableToGetPrivateLookupFor(String className); @LogMessage(level = INFO) - @Message(value = "Using JtaPlatform implementation: [%s]", id = 490) + @Message(value = "No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)", id = 489) + void noJtaPlatform(); + + @LogMessage(level = INFO) + @Message(value = "Using JTA platform [%s]", id = 490) void usingJtaPlatform(String jtaPlatformClassName); @LogMessage(level = WARN) diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/GenerationTargetToDatabase.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/GenerationTargetToDatabase.java index 60d3f2cb4a..694262cb21 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/GenerationTargetToDatabase.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/GenerationTargetToDatabase.java @@ -66,7 +66,9 @@ public void prepare() { @Override public void beforeScript(ScriptSourceInput scriptSource) { - log.executingScript( scriptSource.getScriptDescription() ); + if ( scriptSource.exists() ) { + log.executingScript( scriptSource.getScriptDescription() ); + } } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputAggregate.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputAggregate.java index a6a178c545..03c2e5c3dc 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputAggregate.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputAggregate.java @@ -45,14 +45,16 @@ public List extract(Function> extractor) { int size = 0; for ( int i = 0; i < inputs.length; i++ ) { final AbstractScriptSourceInput scriptSourceInput = inputs[i]; - final Reader reader = scriptSourceInput.prepareReader(); - try { - log.executingScript( scriptSourceInput.getScriptDescription() ); - lists[i] = extractor.apply( reader ); - size += lists[i].size(); - } - finally { - scriptSourceInput.releaseReader( reader ); + if ( scriptSourceInput.exists() ) { + final Reader reader = scriptSourceInput.prepareReader(); + try { + log.executingScript( scriptSourceInput.getScriptDescription() ); + lists[i] = extractor.apply( reader ); + size += lists[i].size(); + } + finally { + scriptSourceInput.releaseReader( reader ); + } } } final List list = new ArrayList<>( size ); diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputNonExistentImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputNonExistentImpl.java index 1eee1a192a..c3e5d105e9 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputNonExistentImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputNonExistentImpl.java @@ -49,4 +49,9 @@ public boolean containsScript(URL url) { public List extract(Function> extractor) { return Collections.emptyList(); } + + @Override + public boolean exists() { + return false; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ScriptSourceInput.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ScriptSourceInput.java index f12c2c7305..5c6a25c842 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ScriptSourceInput.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ScriptSourceInput.java @@ -32,4 +32,8 @@ default boolean containsScript(URL url) { return false; } + default boolean exists() { + return true; + } + } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/JtaPlatformLoggingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/JtaPlatformLoggingTest.java index 715d47b7a4..7f66e42775 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/JtaPlatformLoggingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/JtaPlatformLoggingTest.java @@ -25,7 +25,7 @@ import org.jboss.logging.Logger; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * @author Vlad Mihalcea @@ -47,10 +47,7 @@ protected void addSettings(Map settings) { @Test public void test() { - assertEquals( - "HHH000490: Using JtaPlatform implementation: [org.hibernate.testing.jta.TestingJtaPlatformImpl]", - triggerable.triggerMessage() - ); + assertTrue( triggerable.triggerMessage().startsWith("HHH000490: Using JTA platform")); } @Override