diff --git a/build.gradle b/build.gradle index efb969cc55..c3ed562a58 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ libraries = [ // logging logging: 'org.jboss.logging:jboss-logging:3.0.0.Beta4', - logging_tools: 'org.jboss.logging:jboss-logging-tools:1.0.0.Beta1', + // logging_tools: 'org.jboss.logging:jboss-logging-tools:1.0.0.Beta2', slf4j_api: 'org.slf4j:slf4j-api:' + slf4jVersion, slf4j_simple: 'org.slf4j:slf4j-simple:' + slf4jVersion, jcl_slf4j: 'org.slf4j:jcl-over-slf4j:' + slf4jVersion, @@ -108,7 +108,7 @@ subprojects { subProject -> // appropriately inject the common dependencies into each sub-project dependencies { compile(libraries.logging) - compile(libraries.logging_tools) + // compile(libraries.logging_tools) compile( libraries.slf4j_api ) testCompile( libraries.junit ) testRuntime( libraries.slf4j_simple ) @@ -136,7 +136,7 @@ subprojects { subProject -> test { systemProperties['hibernate.test.validatefailureexpected'] = true - // systemProperties['jboss.i18n.generate-proxies'] = true + systemProperties['jboss.i18n.generate-proxies'] = true maxHeapSize = "1024m" } diff --git a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java index 36ce88526d..ed62de1989 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java @@ -176,7 +176,7 @@ public class C3P0ConnectionProvider implements ConnectionProvider { } catch ( Exception e ) { LOG.error(LOG.unableToInstantiateC3p0ConnectionPool(), e); - throw new HibernateException( "Could not instantiate C3P0 connection pool", e ); + throw new HibernateException(LOG.unableToInstantiateC3p0ConnectionPool(), e); } String i = props.getProperty( Environment.ISOLATION ); diff --git a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0Logger.java b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0Logger.java index 8cadc137d2..b611be4791 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0Logger.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0Logger.java @@ -57,5 +57,5 @@ public interface C3P0Logger extends BasicLogger { Object unableToDestroyC3p0ConnectionPool(); @Message( value = "Could not instantiate C3P0 connection pool" ) - Object unableToInstantiateC3p0ConnectionPool(); + String unableToInstantiateC3p0ConnectionPool(); } diff --git a/hibernate-core/src/main/java/org/hibernate/LogUtil.java b/hibernate-core/src/main/java/org/hibernate/LogUtil.java deleted file mode 100644 index 5f2301a6e9..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/LogUtil.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * - * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing. - * - * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors. - */ -package org.hibernate; - -/** - * - */ -public class LogUtil { - - public static final org.jboss.logging.Logger TMP_LOG = org.jboss.logging.Logger.getLogger(LogUtil.class); -} diff --git a/hibernate-core/src/main/java/org/hibernate/Logger.java b/hibernate-core/src/main/java/org/hibernate/Logger.java index d4677e844a..3d498b4f48 100644 --- a/hibernate-core/src/main/java/org/hibernate/Logger.java +++ b/hibernate-core/src/main/java/org/hibernate/Logger.java @@ -14,6 +14,7 @@ import static org.jboss.logging.Logger.Level.WARN; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.net.URISyntaxException; import java.net.URL; import java.sql.SQLException; import java.sql.SQLWarning; @@ -21,9 +22,11 @@ import java.util.Hashtable; import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; +import javax.naming.InvalidNameException; +import javax.naming.NameNotFoundException; import javax.naming.NamingException; import javax.transaction.Synchronization; +import javax.transaction.SystemException; import org.hibernate.cache.CacheException; import org.hibernate.cfg.AccessType; import org.hibernate.dialect.Dialect; @@ -33,23 +36,26 @@ import org.hibernate.engine.loading.CollectionLoadContext; import org.hibernate.engine.loading.EntityLoadContext; import org.hibernate.id.IntegralDataTypeHolder; import org.hibernate.service.jdbc.dialect.internal.AbstractDialectResolver; -import org.hibernate.service.spi.Service; import org.hibernate.type.BasicType; import org.hibernate.type.SerializationException; import org.hibernate.type.Type; import org.jboss.logging.BasicLogger; +import org.jboss.logging.Cause; import org.jboss.logging.LogMessage; import org.jboss.logging.Message; import org.jboss.logging.MessageLogger; /** - * Interface defining messages that may be logged by the outer class + * Defines internationalized messages for hibernate-core. New messages must be added after the last message defined to ensure + * message codes are unique. */ -@MessageLogger +// TODO: @cause, errorv because of var args and reordering of parameters, combine loggers in hibernate-core, +// formattable, message codes, register project code, category=class, rename Log +@MessageLogger( projectCode = "HHH" ) public interface Logger extends BasicLogger { @LogMessage( level = INFO ) - @Message( value = "Adding secondary table to entity %s -> %s" ) + @Message( "Adding secondary table to entity %s -> %s" ) void addingSecondaryTableToEntity( String entity, String table ); @@ -129,6 +135,10 @@ public interface Logger extends BasicLogger { @Message( value = "Binding type definition: %s" ) void bindingTypeDefinition( String name ); + @LogMessage( level = INFO ) + @Message( value = "Bound Ejb3Configuration to JNDI name: %s" ) + void boundEjb3ConfigurationToJndiName( String name ); + @LogMessage( level = INFO ) @Message( value = "Building session factory" ) void buildingSessionFactory(); @@ -158,6 +168,10 @@ public interface Logger extends BasicLogger { @Message( value = "Cache region prefix: %s" ) void cacheRegionPrefix( String prefix ); + @LogMessage( level = WARN ) + @Message( value = "Calling joinTransaction() on a non JTA EntityManager" ) + void callingJoinTransactionOnNonJtaEntityManager(); + @LogMessage( level = INFO ) @Message( value = "Check Nullability in Core (should be disabled when Bean Validation is on): %s" ) void checkNullability( String enabledDisabled ); @@ -170,42 +184,22 @@ public interface Logger extends BasicLogger { @Message( value = "Closing" ) void closing(); - @LogMessage( level = INFO ) - @Message( value = "Collections fetched (minimize this): %s" ) - void collectionsFetched( AtomicLong collectionFetchCount ); - @LogMessage( level = INFO ) @Message( value = "Collections fetched (minimize this): %ld" ) void collectionsFetched( long collectionFetchCount ); - @LogMessage( level = INFO ) - @Message( value = "Collections loaded: %s" ) - void collectionsLoaded( AtomicLong collectionLoadCount ); - @LogMessage( level = INFO ) @Message( value = "Collections loaded: %ld" ) void collectionsLoaded( long collectionLoadCount ); - @LogMessage( level = INFO ) - @Message( value = "Collections recreated: %s" ) - void collectionsRecreated( AtomicLong collectionRecreateCount ); - @LogMessage( level = INFO ) @Message( value = "Collections recreated: %ld" ) void collectionsRecreated( long collectionRecreateCount ); - @LogMessage( level = INFO ) - @Message( value = "Collections removed: %s" ) - void collectionsRemoved( AtomicLong collectionRemoveCount ); - @LogMessage( level = INFO ) @Message( value = "Collections removed: %ld" ) void collectionsRemoved( long collectionRemoveCount ); - @LogMessage( level = INFO ) - @Message( value = "Collections updated: %s" ) - void collectionsUpdated( AtomicLong collectionUpdateCount ); - @LogMessage( level = INFO ) @Message( value = "Collections updated: %ld" ) void collectionsUpdated( long collectionUpdateCount ); @@ -246,10 +240,6 @@ public interface Logger extends BasicLogger { @Message( value = "Connection release mode: %s" ) void connectionReleaseMode( String releaseModeName ); - @LogMessage( level = INFO ) - @Message( value = "Connections obtained: %s" ) - void connectionsObtained( AtomicLong connectCount ); - @LogMessage( level = INFO ) @Message( value = "Connections obtained: %ld" ) void connectionsObtained( long connectCount ); @@ -258,6 +248,10 @@ public interface Logger extends BasicLogger { @Message( value = "%s did not provide constructor accepting java.util.Properties; attempting no-arg constructor." ) void constructorWithPropertiesNotFound( String regionFactoryClassName ); + @LogMessage( level = ERROR ) + @Message( value = "Container is providing a null PersistenceUnitRootUrl: discovery impossible" ) + void containerProvidingNullPersistenceUnitRootUrl(); + @LogMessage( level = WARN ) @Message( value = "Ignoring bag join fetch [%s] due to prior collection join fetch" ) void containsJoinFetchedCollection( String role ); @@ -270,9 +264,7 @@ public interface Logger extends BasicLogger { void creatingSubcontextInfo( String intermediateContextName ); @LogMessage( level = INFO ) - // @formatter:off @Message( value = "Database ->\n" + " name : %s\n" + " version : %s\n" + " major : %s\n" + " minor : %s" ) - // @formatter:on void database( String databaseProductName, String databaseProductVersion, int databaseMajorVersion, @@ -294,6 +286,10 @@ public interface Logger extends BasicLogger { @Message( value = "Default schema: %s" ) void defaultSchema( String defaultSchema ); + @LogMessage( level = WARN ) + @Message( value = "Defining %s=true ignored in HEM" ) + void definingFlushBeforeCompletionIgnoredInHem( String flushBeforeCompletion ); + @LogMessage( level = INFO ) @Message( value = "Deleted entity synthetic identifier rollback: %s" ) void deletedEntitySyntheticIdentifierRollback( String enabledDisabled ); @@ -328,9 +324,7 @@ public interface Logger extends BasicLogger { void disallowingInsertStatementComment(); @LogMessage( level = INFO ) - // @formatter:off @Message( value = "Driver ->\n" + " name : %s\n" + " version : %s\n" + " major : %s\n" + " minor : %s" ) - // @formatter:on void driver( String driverProductName, String driverProductVersion, int driverMajorVersion, @@ -366,41 +360,33 @@ public interface Logger extends BasicLogger { void echoingSql(); @LogMessage( level = INFO ) - @Message( value = "Entities deleted: %s" ) - void entitiesDeleted( AtomicLong entityDeleteCount ); + @Message( value = "Ejb3Configuration name: %s" ) + void ejb3ConfigurationName( String name ); + + @LogMessage( level = INFO ) + @Message( value = "An Ejb3Configuration was renamed from name: %s" ) + void ejb3ConfigurationRenamedFromName( String name ); + + @LogMessage( level = INFO ) + @Message( value = "An Ejb3Configuration was unbound from name: %s" ) + void ejb3ConfigurationUnboundFromName( String name ); @LogMessage( level = INFO ) @Message( value = "Entities deleted: %ld" ) void entitiesDeleted( long entityDeleteCount ); - @LogMessage( level = INFO ) - @Message( value = "Entities fetched (minimize this): %s" ) - void entitiesFetched( AtomicLong entityFetchCount ); - @LogMessage( level = INFO ) @Message( value = "Entities fetched (minimize this): %ld" ) void entitiesFetched( long entityFetchCount ); - @LogMessage( level = INFO ) - @Message( value = "Entities inserted: %s" ) - void entitiesInserted( AtomicLong entityInsertCount ); - @LogMessage( level = INFO ) @Message( value = "Entities inserted: %ld" ) void entitiesInserted( long entityInsertCount ); - @LogMessage( level = INFO ) - @Message( value = "Entities loaded: %s" ) - void entitiesLoaded( AtomicLong entityLoadCount ); - @LogMessage( level = INFO ) @Message( value = "Entities loaded: %ld" ) void entitiesLoaded( long entityLoadCount ); - @LogMessage( level = INFO ) - @Message( value = "Entities updated: %s" ) - void entitiesUpdated( AtomicLong entityUpdateCount ); - @LogMessage( level = INFO ) @Message( value = "Entities updated: %ld" ) void entitiesUpdated( long entityUpdateCount ); @@ -409,11 +395,35 @@ public interface Logger extends BasicLogger { @Message( value = "@org.hibernate.annotations.Entity used on a non root entity: ignored for %s" ) void entityAnnotationOnNonRoot( String className ); - @Message( value = "Exception in interceptor afterTransactionCompletion()" ) - Object exceptionInAfterTransactionCompletionInterceptor(); + @LogMessage( level = WARN ) + @Message( value = "Entity Manager closed by someone else (%s must not be used)" ) + void entityManagerClosedBySomeoneElse( String autoCloseSession ); + @LogMessage( level = INFO ) + @Message( value = "Hibernate EntityManager %s" ) + void entityManagerVersion( String versionString ); + + @LogMessage( level = WARN ) + @Message( value = "Entity [%s] is abstract-class/interface explicitly mapped as non-abstract; be sure to supply entity-names" ) + void entityMappedAsNonAbstract( String name ); + + @LogMessage( level = INFO ) + @Message( value = "%s %s found" ) + void exceptionHeaderFound( String exceptionHeader, + String metaInfOrmXml ); + + @LogMessage( level = INFO ) + @Message( value = "%s No %s found" ) + void exceptionHeaderNotFound( String exceptionHeader, + String metaInfOrmXml ); + + @LogMessage( level = ERROR ) + @Message( value = "Exception in interceptor afterTransactionCompletion()" ) + void exceptionInAfterTransactionCompletionInterceptor( @Cause Throwable e ); + + @LogMessage( level = ERROR ) @Message( value = "Exception in interceptor beforeTransactionCompletion()" ) - Object exceptionInBeforeTransactionCompletionInterceptor(); + void exceptionInBeforeTransactionCompletionInterceptor( @Cause Throwable e ); @LogMessage( level = INFO ) @Message( value = "Sub-resolver threw unexpected exception, continuing to next : %s" ) @@ -432,6 +442,14 @@ public interface Logger extends BasicLogger { @Message( value = "An item was expired by the cache while it was locked (increase your cache timeout): %s" ) void expired( Object key ); + @LogMessage( level = WARN ) + @Message( value = "Exploded jar file does not exist (ignored): %s" ) + void explodedJarDoesNotExist( URL jarUrl ); + + @LogMessage( level = WARN ) + @Message( value = "Exploded jar file not a directory (ignored): %s" ) + void explodedJarNotDirectory( URL jarUrl ); + @LogMessage( level = INFO ) @Message( value = "Exporting generated schema to database" ) void exportingGeneratedSchemaToDatabase(); @@ -463,11 +481,11 @@ public interface Logger extends BasicLogger { @LogMessage( level = WARN ) @Message( value = "Fail-safe cleanup (collections) : %s" ) - void failSafeCleanup( CollectionLoadContext collectionLoadContext ); + void failSafeCollectionsCleanup( CollectionLoadContext collectionLoadContext ); @LogMessage( level = WARN ) @Message( value = "Fail-safe cleanup (entities) : %s" ) - void failSafeCleanup( EntityLoadContext entityLoadContext ); + void failSafeEntitiesCleanup( EntityLoadContext entityLoadContext ); @LogMessage( level = INFO ) @Message( value = "Fetching database metadata" ) @@ -481,10 +499,6 @@ public interface Logger extends BasicLogger { @Message( value = "firstResult/maxResults specified with collection fetch; applying in memory!" ) void firstOrMaxResultsSpecifiedWithCollectionFetch(); - @LogMessage( level = INFO ) - @Message( value = "Flushes: %s" ) - void flushes( AtomicLong flushCount ); - @LogMessage( level = INFO ) @Message( value = "Flushes: %ld" ) void flushes( long flushCount ); @@ -513,6 +527,11 @@ public interface Logger extends BasicLogger { @Message( value = "Generate SQL with comments: %s" ) void generateSqlWithComments( String enabledDisabled ); + @LogMessage( level = ERROR ) + @Message( value = "Getters of lazy classes cannot be final: %s.%s" ) + void gettersOfLazyClassesCannotBeFinal( String entityName, + String name ); + @LogMessage( level = WARN ) @Message( value = "GUID identifier generated: %s" ) void guidGenerated( String result ); @@ -549,6 +568,17 @@ public interface Logger extends BasicLogger { @Message( value = "Ignoring unique constraints specified on table generator [%s]" ) void ignoringTableGeneratorConstraints( String name ); + @LogMessage( level = INFO ) + @Message( value = "Ignoring unrecognized query hint [%s]" ) + void ignoringUnrecognizedQueryHint( String hintName ); + + @LogMessage( level = ERROR ) + @Message( value = "Illegal argument on static metamodel field injection : %s#%s; expected type : %s; encountered type : %s" ) + void illegalArgumentOnStaticMetamodelFieldInjection( String name, + String name2, + String name3, + String name4 ); + @LogMessage( level = ERROR ) @Message( value = "IllegalArgumentException in class: %s, getter method of property: %s" ) void illegalPropertyGetterArgument( String name, @@ -575,6 +605,10 @@ public interface Logger extends BasicLogger { @Message( value = "InitialContext did not implement EventContext" ) void initialContextDidNotImplementEventContext(); + @LogMessage( level = WARN ) + @Message( value = "InitialContext did not implement EventContext" ) + void initialContextDoesNotImplementEventContext(); + @LogMessage( level = INFO ) @Message( value = "Instantiated TransactionManagerLookup" ) void instantiatedTransactionManagerLookup(); @@ -599,8 +633,10 @@ public interface Logger extends BasicLogger { @Message( value = "Application attempted to edit read only item: %s" ) void invalidEditOfReadOnlyItem( Object key ); + @LogMessage( level = ERROR ) @Message( value = "Invalid JNDI name: %s" ) - Object invalidJndiName( String name ); + void invalidJndiName( String name, + @Cause InvalidNameException e ); @LogMessage( level = WARN ) @Message( value = "Inapropriate use of @OnDelete on entity, annotation ignored: %s" ) @@ -622,10 +658,20 @@ public interface Logger extends BasicLogger { @Message( value = "JACC contextID: %s" ) void jaccContextId( String contextId ); + @LogMessage( level = INFO ) + @Message( value = "java.sql.Types mapped the same code [%d] multiple times; was [%s]; now [%s]" ) + void JavaSqlTypesMappedSameCodeMultipleTimes( int code, + String old, + String name ); + @LogMessage( level = INFO ) @Message( value = "JDBC3 getGeneratedKeys(): %s" ) void jdbc3GeneratedKeys( String enabledDisabled ); + @LogMessage( level = WARN ) + @Message( value = "%s = false break the EJB3 specification" ) + void jdbcAutoCommitFalseBreaksEjb3Spec( String autocommit ); + @LogMessage( level = INFO ) @Message( value = "JDBC batch size: %s" ) void jdbcBatchSize( int batchSize ); @@ -664,13 +710,19 @@ public interface Logger extends BasicLogger { @Message( value = "JNDI InitialContext properties:%s" ) void jndiInitialContextProperties( Hashtable hash ); + @LogMessage( level = ERROR ) @Message( value = "JNDI name %s does not handle a session factory reference" ) - Object jndiNameDoesNotHandleSessionFactoryReference( String sfJNDIName ); + void jndiNameDoesNotHandleSessionFactoryReference( String sfJNDIName, + @Cause ClassCastException e ); @LogMessage( level = INFO ) @Message( value = "JPA-QL strict compliance: %s" ) void jpaQlStrictCompliance( String enabledDisabled ); + @LogMessage( level = INFO ) + @Message( value = "Lazy property fetching available for: %s" ) + void lazyPropertyFetchingAvailable( String name ); + @LogMessage( level = INFO ) @Message( value = "JVM does not support LinkedHashMap, LinkedHashSet - ordered maps and sets disabled" ) void linkedMapsAndSetsNotSupported(); @@ -695,6 +747,16 @@ public interface Logger extends BasicLogger { @Message( value = "Logical connection releasing its physical connection" ) void logicalConnectionReleasingPhysicalConnection(); + @LogMessage( level = ERROR ) + @Message( value = "Malformed URL: %s" ) + void malformedUrl( URL jarUrl, + @Cause URISyntaxException e ); + + @LogMessage( level = WARN ) + @Message( value = "Malformed URL: %s" ) + void malformedUrlWarning( URL jarUrl, + @Cause URISyntaxException e ); + @LogMessage( level = WARN ) @Message( value = "You should set hibernate.transaction.manager_lookup_class if cache is enabled" ) void managerLookupClassShouldBeSet(); @@ -737,10 +799,6 @@ public interface Logger extends BasicLogger { @Message( value = "Maximum outer join fetch depth: %s" ) void maxOuterJoinFetchDepth( Integer maxFetchDepth ); - @LogMessage( level = INFO ) - @Message( value = "Max query time: %sms" ) - void maxQueryTime( AtomicLong queryExecutionMaxTime ); - @LogMessage( level = INFO ) @Message( value = "Max query time: %ldms" ) void maxQueryTime( long queryExecutionMaxTime ); @@ -758,8 +816,10 @@ public interface Logger extends BasicLogger { @Message( value = "Named query checking : %s" ) void namedQueryChecking( String enabledDisabled ); + @LogMessage( level = ERROR ) @Message( value = "Error in named query: %s" ) - Object namedQueryError( String queryName ); + void namedQueryError( String queryName, + @Cause HibernateException e ); @LogMessage( level = WARN ) @Message( value = "Naming exception occurred accessing factory: %s" ) @@ -777,12 +837,18 @@ public interface Logger extends BasicLogger { @Message( value = "No appropriate connection provider encountered, assuming application will be supplying connections" ) void noAppropriateConnectionProvider(); + @LogMessage( level = INFO ) + @Message( value = "No default (no-argument) constructor for class: %s (class must be instantiated by Interceptor)" ) + void noDefaultConstructor( String name ); + @LogMessage( level = WARN ) @Message( value = "no persistent classes found for query class: %s" ) void noPersistentClassesFound( String query ); + @LogMessage( level = ERROR ) @Message( value = "No session factory with JNDI name %s" ) - Object noSessionFactoryWithJndiName( String sfJNDIName ); + void noSessionFactoryWithJndiName( String sfJNDIName, + @Cause NameNotFoundException e ); @LogMessage( level = INFO ) @Message( value = "Not binding factory to JNDI, no JNDI name configured" ) @@ -792,10 +858,6 @@ public interface Logger extends BasicLogger { @Message( value = "Obtaining TransactionManager" ) void obtainingTransactionManager(); - @LogMessage( level = INFO ) - @Message( value = "Optimistic lock failures: %s" ) - void optimisticLockFailures( AtomicLong optimisticFailureCount ); - @LogMessage( level = INFO ) @Message( value = "Optimistic lock failures: %ld" ) void optimisticLockFailures( long optimisticFailureCount ); @@ -820,10 +882,45 @@ public interface Logger extends BasicLogger { @Message( value = "Order SQL updates by primary key: %s" ) void orderSqlUpdatesByPrimaryKey( String enabledDisabled ); + @LogMessage( level = WARN ) + @Message( value = "Overriding %s is dangerous, this might break the EJB3 specification implementation" ) + void overridingTransactionStrategyDangerous( String transactionStrategy ); + @LogMessage( level = WARN ) @Message( value = "Package not found or wo package-info.java: %s" ) void packageNotFound( String packageName ); + @LogMessage( level = WARN ) + @Message( value = "Parameter position [%s] occurred as both JPA and Hibernate positional parameter" ) + void parameterPositionOccurredAsBothJpaAndHibernatePositionalParameter( Integer position ); + + @LogMessage( level = ERROR ) + @Message( value = "Error parsing XML (%d) : %s" ) + void parsingXmlError( int lineNumber, + String message ); + + @LogMessage( level = ERROR ) + @Message( value = "Error parsing XML: %s(%d) %s" ) + void parsingXmlErrorForFile( String file, + int lineNumber, + String message ); + + @LogMessage( level = ERROR ) + @Message( value = "Warning parsing XML (%d) : %s" ) + void parsingXmlWarning( int lineNumber, + String message ); + + @LogMessage( level = WARN ) + @Message( value = "Warning parsing XML: %s(%d) %s" ) + void parsingXmlWarningForFile( String file, + int lineNumber, + String message ); + + @LogMessage( level = WARN ) + @Message( value = "Persistence provider caller does not implement the EJB3 spec correctly." + + "PersistenceUnitInfo.getNewTempClassLoader() is null." ) + void persistenceProviderCallerDoesNotImplementEjb3SpecCorrectly(); + @LogMessage( level = INFO ) @Message( value = "Pooled optimizer source reported [%s] as the initial value; use of 1 or greater highly recommended" ) void pooledOptimizerReportedInitialValue( IntegralDataTypeHolder value ); @@ -836,6 +933,10 @@ public interface Logger extends BasicLogger { @Message( value = "processEqualityExpression() : No expression to process!" ) void processEqualityExpression(); + @LogMessage( level = INFO ) + @Message( value = "Processing PersistenceUnitInfo [\n\tname: %s\n\t...]" ) + void processingPersistenceUnitInfoName( String persistenceUnitName ); + @LogMessage( level = INFO ) @Message( value = "Loaded properties from resource hibernate.properties: %s" ) void propertiesLoaded( Properties maskOut ); @@ -857,10 +958,6 @@ public interface Logger extends BasicLogger { @Message( value = "proxool properties were encountered, but the %s provider class was not found on the classpath; these properties are going to be ignored." ) void proxoolProviderClassNotFound( String proxoolProviderClassName ); - @LogMessage( level = INFO ) - @Message( value = "Queries executed to database: %s" ) - void queriesExecuted( AtomicLong queryExecutionCount ); - @LogMessage( level = INFO ) @Message( value = "Queries executed to database: %ld" ) void queriesExecuted( long queryExecutionCount ); @@ -873,33 +970,21 @@ public interface Logger extends BasicLogger { @Message( value = "Query cache factory: %s" ) void queryCacheFactory( String queryCacheFactoryClassName ); - @LogMessage( level = INFO ) - @Message( value = "Query cache hits: %s" ) - void queryCacheHits( AtomicLong queryCacheHitCount ); - @LogMessage( level = INFO ) @Message( value = "Query cache hits: %ld" ) void queryCacheHits( long queryCacheHitCount ); - @LogMessage( level = INFO ) - @Message( value = "Query cache misses: %s" ) - void queryCacheMisses( AtomicLong queryCacheMissCount ); - @LogMessage( level = INFO ) @Message( value = "Query cache misses: %ld" ) void queryCacheMisses( long queryCacheMissCount ); - @LogMessage( level = INFO ) - @Message( value = "Query cache puts: %s" ) - void queryCachePuts( AtomicLong queryCachePutCount ); - @LogMessage( level = INFO ) @Message( value = "Query cache puts: %ld" ) void queryCachePuts( long queryCachePutCount ); @LogMessage( level = INFO ) @Message( value = "Query language substitutions: %s" ) - void queryLanguageSubstitutions( Map querySubstitutions ); + void queryLanguageSubstitutions( Map querySubstitutions ); @LogMessage( level = INFO ) @Message( value = "Query translator: %s" ) @@ -925,6 +1010,11 @@ public interface Logger extends BasicLogger { @Message( value = "read-only cache configured for mutable collection [%s]" ) void readOnlyCacheConfiguredForMutableCollection( String name ); + @LogMessage( level = WARN ) + @Message( value = "Recognized obsolete hibernate namespace %s. Use namespace %s instead. Refer to Hibernate 3.6 Migration Guide!" ) + void recognizedObsoleteHibernateNamespace( String oldHibernateNamespace, + String hibernateNamespace ); + @LogMessage( level = WARN ) @Message( value = "Reconnecting the same connection that is already connected; should this connection have been disconnected?" ) void reconnectingConnectedConnection(); @@ -934,6 +1024,10 @@ public interface Logger extends BasicLogger { void renamedProperty( Object propertyName, Object newPropertyName ); + @LogMessage( level = INFO ) + @Message( value = "Required a different provider: %s" ) + void requiredDifferentProvider( String provider ); + @LogMessage( level = INFO ) @Message( value = "Running hbm2ddl schema export" ) void runningHbm2ddlSchemaExport(); @@ -950,13 +1044,19 @@ public interface Logger extends BasicLogger { @Message( value = "Schema export complete" ) void schemaExportComplete(); + @LogMessage( level = ERROR ) @Message( value = "Schema export unsuccessful" ) - Object schemaExportUnsuccessful(); + void schemaExportUnsuccessful( @Cause Exception e ); @LogMessage( level = INFO ) @Message( value = "Schema update complete" ) void schemaUpdateComplete(); + @LogMessage( level = WARN ) + @Message( value = "Scoping types to session factory %s after already scoped %s" ) + void scopingTypesToSessionFactoryAfterAlreadyScoped( SessionFactoryImplementor factory, + SessionFactoryImplementor factory2 ); + @LogMessage( level = INFO ) @Message( value = "Scrollable result sets: %s" ) void scrollabelResultSets( String enabledDisabled ); @@ -969,26 +1069,14 @@ public interface Logger extends BasicLogger { @Message( value = "Second-level cache: %s" ) void secondLevelCache( String enabledDisabled ); - @LogMessage( level = INFO ) - @Message( value = "Second level cache hits: %s" ) - void secondLevelCacheHits( AtomicLong secondLevelCacheHitCount ); - @LogMessage( level = INFO ) @Message( value = "Second level cache hits: %ld" ) void secondLevelCacheHits( long secondLevelCacheHitCount ); - @LogMessage( level = INFO ) - @Message( value = "Second level cache misses: %s" ) - void secondLevelCacheMisses( AtomicLong secondLevelCacheMissCount ); - @LogMessage( level = INFO ) @Message( value = "Second level cache misses: %ld" ) void secondLevelCacheMisses( long secondLevelCacheMissCount ); - @LogMessage( level = INFO ) - @Message( value = "Second level cache puts: %s" ) - void secondLevelCachePuts( AtomicLong secondLevelCachePutCount ); - @LogMessage( level = INFO ) @Message( value = "Second level cache puts: %ld" ) void secondLevelCachePuts( long secondLevelCachePutCount ); @@ -997,22 +1085,19 @@ public interface Logger extends BasicLogger { @Message( value = "Service properties: %s" ) void serviceProperties( Properties properties ); - @LogMessage( level = INFO ) - @Message( value = "Sessions closed: %s" ) - void sessionsClosed( AtomicLong sessionCloseCount ); - @LogMessage( level = INFO ) @Message( value = "Sessions closed: %ld" ) void sessionsClosed( long sessionCloseCount ); - @LogMessage( level = INFO ) - @Message( value = "Sessions opened: %s" ) - void sessionsOpened( AtomicLong sessionOpenCount ); - @LogMessage( level = INFO ) @Message( value = "Sessions opened: %ld" ) void sessionsOpened( long sessionOpenCount ); + @LogMessage( level = ERROR ) + @Message( value = "Setters of lazy classes cannot be final: %s.%s" ) + void settersOfLazyClassesCannotBeFinal( String entityName, + String name ); + @LogMessage( level = WARN ) @Message( value = "@Sort not allowed for an indexed collection, annotation ignored." ) void sortAnnotationIndexedCollection(); @@ -1022,8 +1107,19 @@ public interface Logger extends BasicLogger { void splitQueries( String sourceQuery, int length ); + @LogMessage( level = WARN ) + @Message( value = "SQL Error: %d, SQLState: %s" ) + void sqlError( int errorCode, + String sqlState ); + + @LogMessage( level = WARN ) + @Message( value = "SQL Error: %d, SQLState: %s" ) + void sqlException( int errorCode, + String sqlState ); + + @LogMessage( level = ERROR ) @Message( value = "SQLException escaped proxy" ) - Object sqlExceptionEscapedProxy(); + void sqlExceptionEscapedProxy( @Cause SQLException e ); @LogMessage( level = INFO ) @Message( value = "Starting query cache at region: %s" ) @@ -1041,18 +1137,10 @@ public interface Logger extends BasicLogger { @Message( value = "Start time: %s" ) void startTime( long startTime ); - @LogMessage( level = INFO ) - @Message( value = "Statements closed: %s" ) - void statementsClosed( AtomicLong closeStatementCount ); - @LogMessage( level = INFO ) @Message( value = "Statements closed: %ld" ) void statementsClosed( long closeStatementCount ); - @LogMessage( level = INFO ) - @Message( value = "Statements prepared: %s" ) - void statementsPrepared( AtomicLong prepareStatementCount ); - @LogMessage( level = INFO ) @Message( value = "Statements prepared: %ld" ) void statementsPrepared( long prepareStatementCount ); @@ -1073,10 +1161,6 @@ public interface Logger extends BasicLogger { @Message( value = "sub-resolver threw unexpected exception, continuing to next : %s" ) void subResolverException( String message ); - @LogMessage( level = INFO ) - @Message( value = "Successful transactions: %s" ) - void successfulTransactions( AtomicLong committedTransactionCount ); - @LogMessage( level = INFO ) @Message( value = "Successful transactions: %ld" ) void successfulTransactions( long committedTransactionCount ); @@ -1098,9 +1182,6 @@ public interface Logger extends BasicLogger { @Message( value = "Table not found: %s" ) void tableNotFound( String name ); - @Message( value = "TransactionFactory class not found" ) - String transactionFactoryClassNotFound(); - @Message( value = "TransactionFactory class not found: %s" ) String transactionFactoryClassNotFound( String strategyClassName ); @@ -1108,9 +1189,9 @@ public interface Logger extends BasicLogger { @Message( value = "No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)" ) void transactionManagerLookupNotConfigured(); - @LogMessage( level = INFO ) - @Message( value = "Transactions: %s" ) - void transactions( AtomicLong transactionCount ); + @LogMessage( level = WARN ) + @Message( value = "Transaction not available on beforeCompletion: assuming valid" ) + void transactionNotAvailableOnBeforeCompletion(); @LogMessage( level = INFO ) @Message( value = "Transactions: %ld" ) @@ -1124,8 +1205,22 @@ public interface Logger extends BasicLogger { @Message( value = "Transaction strategy: %s" ) void transactionStrategy( String strategyClassName ); + @LogMessage( level = WARN ) + @Message( value = "Type [%s] defined no registration keys; ignoring" ) + void typeDefinedNoRegistrationKeys( BasicType type ); + + @LogMessage( level = INFO ) + @Message( value = "Type registration [%s] overrides previous : %s" ) + void typeRegistrationOverridesPrevious( String key, + Type old ); + + @Message( value = "Naming exception occurred accessing Ejb3Configuration" ) + Object unableToAccessEjb3Configuration(); + + @LogMessage( level = ERROR ) @Message( value = "Error while accessing session factory with JNDI name %s" ) - Object unableToAccessSessionFactory( String sfJNDIName ); + void unableToAccessSessionFactory( String sfJNDIName, + @Cause NamingException e ); @LogMessage( level = WARN ) @Message( value = "Error accessing type info result set : %s" ) @@ -1134,17 +1229,21 @@ public interface Logger extends BasicLogger { @Message( value = "Unable to apply constraints on DDL for %s" ) Object unableToApplyConstraints( String className ); - @LogMessage( level = WARN ) - @Message( value = "Unable to apply constraints on DDL for %s : %s" ) - void unableToApplyConstraints( String className, - String message ); - @Message( value = "JTA transaction begin failed" ) String unableToBeginJtaTransaction(); + @Message( value = "Could not bind Ejb3Configuration to JNDI" ) + Object unableToBindEjb3ConfigurationToJndi(); + @Message( value = "Could not bind factory to JNDI" ) Object unableToBindFactoryToJndi(); + @LogMessage( level = INFO ) + @Message( value = "Could not bind value '%s' to parameter: %d; %s" ) + void unableToBindValueToParameter( String nullSafeToString, + int index, + String message ); + @LogMessage( level = ERROR ) @Message( value = "Unable to build enhancement metamodel for %s" ) void unableToBuildEnhancementMetamodel( String className ); @@ -1153,24 +1252,37 @@ public interface Logger extends BasicLogger { @Message( value = "Could not build SessionFactory using the MBean classpath - will try again using client classpath: %s" ) void unableToBuildSessionFactoryUsingMBeanClasspath( String message ); + @Message( value = "Unable to clean up callable statement" ) + Object unableToCleanUpCallableStatement(); + + @Message( value = "Unable to clean up prepared statement" ) + Object unableToCleanUpPreparedStatement(); + @LogMessage( level = WARN ) @Message( value = "Unable to cleanup temporary id table after use [%s]" ) void unableToCleanupTemporaryIdTable( Throwable t ); + @Message( value = "Could not clear warnings" ) + Object unableToClearWarnings(); + + @LogMessage( level = ERROR ) @Message( value = "Error closing connection" ) - Object unableToCloseConnection(); + void unableToCloseConnection( @Cause Exception e ); @LogMessage( level = INFO ) @Message( value = "Error closing InitialContext [%s]" ) void unableToCloseInitialContext( String string ); + @LogMessage( level = ERROR ) @Message( value = "Error closing imput files: %s" ) - Object unableToCloseInputFiles( String name ); + Object unableToCloseInputFiles( String name, + @Cause IOException e ); - @LogMessage( level = WARN ) - @Message( value = "Could not close input stream for %s : %s" ) - void unableToCloseInputStream( String resourceName, - String message ); + @Message( value = "Could not close input stream" ) + Object unableToCloseInputStream(); + + @Message( value = "Could not close input stream for %s" ) + Object unableToCloseInputStreamForResource( String resourceName ); @Message( value = "Unable to close iterator" ) Object unableToCloseIterator(); @@ -1179,37 +1291,51 @@ public interface Logger extends BasicLogger { @Message( value = "Could not close jar: %s" ) void unableToCloseJar( String message ); + @LogMessage( level = ERROR ) @Message( value = "Error closing output file: %s" ) - Object unableToCloseOutputFile( String outputFile ); + void unableToCloseOutputFile( String outputFile, + @Cause IOException e ); + + @Message( value = "IOException occurred closing output stream" ) + Object unableToCloseOutputStream(); @Message( value = "Problem closing pooled connection" ) Object unableToClosePooledConnection(); + @LogMessage( level = ERROR ) @Message( value = "Could not close session" ) - String unableToCloseSession(); + void unableToCloseSession( @Cause HibernateException e ); + @LogMessage( level = ERROR ) @Message( value = "Could not close session during rollback" ) - String unableToCloseSessionDuringRollback(); + void unableToCloseSessionDuringRollback( @Cause Exception e ); + + @Message( value = "IOException occurred closing stream" ) + Object unableToCloseStream(); @LogMessage( level = ERROR ) @Message( value = "Could not close stream on hibernate.properties: %s" ) - void unableToCloseStream( IOException error ); + void unableToCloseStreamError( IOException error ); @Message( value = "JTA commit failed" ) String unableToCommitJta(); + @LogMessage( level = ERROR ) @Message( value = "Could not complete schema update" ) - Object unableToCompleteSchemaUpdate(); + void unableToCompleteSchemaUpdate( @Cause Exception e ); + @LogMessage( level = ERROR ) @Message( value = "Could not complete schema validation" ) - Object unableToCompleteSchemaValidation(); + void unableToCompleteSchemaValidation( @Cause SQLException e ); @LogMessage( level = WARN ) @Message( value = "Unable to configure SQLExceptionConverter : %s" ) void unableToConfigureSqlExceptionConverter( HibernateException e ); + @LogMessage( level = ERROR ) @Message( value = "Unable to construct current session context [%s]" ) - Object unableToConstructCurrentSessionContext( String impl ); + void unableToConstructCurrentSessionContext( String impl, + @Cause Throwable e ); @LogMessage( level = WARN ) @Message( value = "Unable to construct instance of specified SQLExceptionConverter : %s" ) @@ -1219,8 +1345,12 @@ public interface Logger extends BasicLogger { @Message( value = "Could not copy system properties, system properties will be ignored" ) void unableToCopySystemProperties(); + @Message( value = "Could not create proxy factory for:%s" ) + Object unableToCreateProxyFactory( String entityName ); + + @LogMessage( level = ERROR ) @Message( value = "Error creating schema " ) - Object unableToCreateSchema(); + void unableToCreateSchema( @Cause Exception e ); @LogMessage( level = WARN ) @Message( value = "Could not deserialize cache file: %s : %s" ) @@ -1241,13 +1371,14 @@ public interface Logger extends BasicLogger { void unableToDestroyUpdateTimestampsCache( String region, String message ); + @LogMessage( level = INFO ) + @Message( value = "Unable to determine lock mode value : %s -> %s" ) + void unableToDetermineLockModeValue( String hintName, + Object value ); + @Message( value = "Could not determine transaction status" ) String unableToDetermineTransactionStatus(); - @LogMessage( level = ERROR ) - @Message( value = "Could not determine transaction status [%s]" ) - void unableToDetermineTransactionStatus( String message ); - @Message( value = "Could not determine transaction status after commit" ) String unableToDetermineTransactionStatusAfterCommit(); @@ -1264,17 +1395,20 @@ public interface Logger extends BasicLogger { void unableToExecuteResolver( AbstractDialectResolver abstractDialectResolver, String message ); - @LogMessage( level = WARN ) - @Message( value = "Error executing resolver [%s] : %s" ) - void unableToExecuteResolver( org.hibernate.dialect.resolver.AbstractDialectResolver abstractDialectResolver, - String message ); + @Message( value = "Unable to find file (ignored): %s" ) + Object unableToFindFile( URL jarUrl ); @LogMessage( level = INFO ) @Message( value = "Unable to find %s on the classpath. Hibernate Search is not enabled." ) void unableToFindListenerClass( String className ); + @LogMessage( level = INFO ) + @Message( value = "Could not find any META-INF/persistence.xml file in the classpath" ) + void unableToFindPersistenceXmlInClasspath(); + + @LogMessage( level = ERROR ) @Message( value = "Could not get database metadata" ) - Object unableToGetDatabaseMetadata(); + void unableToGetDatabaseMetadata( @Cause SQLException e ); @LogMessage( level = WARN ) @Message( value = "Unable to instantiate configured schema name resolver [%s] %s" ) @@ -1292,12 +1426,6 @@ public interface Logger extends BasicLogger { @Message( value = "Failed to instantiate TransactionFactory" ) String unableToInstantiateTransactionFactory(); - @Message( value = "Failed to instantiate TransactionFactory: %s" ) - String unableToInstantiateTransactionFactory( Exception error ); - - @Message( value = "Failed to instantiate TransactionManagerLookup" ) - String unableToInstantiateTransactionManagerLookup(); - @Message( value = "Failed to instantiate TransactionManagerLookup '%s'" ) String unableToInstantiateTransactionManagerLookup( String tmLookupClass ); @@ -1305,6 +1433,10 @@ public interface Logger extends BasicLogger { @Message( value = "Unable to instantiate UUID generation strategy class : %s" ) void unableToInstantiateUuidGenerationStrategy( Exception ignore ); + @LogMessage( level = WARN ) + @Message( value = "Cannot join transaction: do not override %s" ) + void unableToJoinTransaction( String transactionStrategy ); + @LogMessage( level = INFO ) @Message( value = "Error performing load command : %s" ) void unableToLoadCommand( HibernateException e ); @@ -1317,6 +1449,9 @@ public interface Logger extends BasicLogger { @Message( value = "Problem loading properties from hibernate.properties" ) void unableToloadProperties(); + @Message( value = "Unable to locate config file: %s" ) + String unableToLocateConfigFile( String path ); + @LogMessage( level = WARN ) @Message( value = "Unable to locate configured schema name resolver class [%s] %s" ) void unableToLocateConfiguredSchemaNameResolver( String resolverClassName, @@ -1326,6 +1461,15 @@ public interface Logger extends BasicLogger { @Message( value = "Unable to locate MBeanServer on JMX service shutdown" ) void unableToLocateMBeanServer(); + @LogMessage( level = INFO ) + @Message( value = "Could not locate 'java.sql.NClob' class; assuming JDBC 3" ) + void unableToLocateNClobClass(); + + @LogMessage( level = ERROR ) + @Message( value = "Unable to locate static metamodel field : %s#%s" ) + void unableToLocateStaticMetamodelField( String name, + String name2 ); + @LogMessage( level = WARN ) @Message( value = "Unable to locate requested UUID generation strategy class : %s" ) void unableToLocateUuidGenerationStrategy( String strategyClassName ); @@ -1334,9 +1478,16 @@ public interface Logger extends BasicLogger { @Message( value = "Unable to log SQLWarnings : %s" ) void unableToLogSqlWarnings( SQLException sqle ); - @LogMessage( level = WARN ) - @Message( value = "Could not log warnings : %s" ) - void unableToLogWarnings( SQLException sqle ); + @Message( value = "Could not log warnings" ) + Object unableToLogWarnings(); + + @LogMessage( level = ERROR ) + @Message( value = "Unable to mark for rollback on PersistenceException: " ) + void unableToMarkForRollbackOnPersistenceException( @Cause Exception e ); + + @LogMessage( level = ERROR ) + @Message( value = "Unable to mark for rollback on TransientObjectException: " ) + void unableToMarkForRollbackOnTransientObjectException( @Cause Exception e ); @LogMessage( level = WARN ) @Message( value = "Could not obtain connection metadata: %s" ) @@ -1354,8 +1505,9 @@ public interface Logger extends BasicLogger { @Message( value = "Could not obtain connection to query metadata : %s" ) void unableToObtainConnectionToQueryMetadata( String message ); + @LogMessage( level = ERROR ) @Message( value = "Could not obtain initial context" ) - Object unableToObtainInitialContext(); + void unableToObtainInitialContext( @Cause NamingException e ); @LogMessage( level = ERROR ) @Message( value = "Could not parse the package-level metadata [%s]" ) @@ -1371,23 +1523,21 @@ public interface Logger extends BasicLogger { @Message( value = "Unable to query java.sql.DatabaseMetaData" ) String unableToQueryDatabaseMetadata(); - @LogMessage( level = WARN ) - @Message( value = "%s : %s" ) - void unableToQueryDatabaseMetadata( String message, - String errorMessage ); - @LogMessage( level = ERROR ) @Message( value = "Unable to read class: %s" ) void unableToReadClass( String message ); - @Message( value = "Could not read a hi value" ) - String unableToReadHiValue(); + @LogMessage( level = INFO ) + @Message( value = "Could not read column value from result set: %s; %s" ) + void unableToReadColumnValueFromResultSet( String name, + String message ); @Message( value = "Could not read a hi value - you need to populate the table: %s" ) String unableToReadHiValue( String tableName ); + @LogMessage( level = ERROR ) @Message( value = "Could not read or init a hi value" ) - Object unableToReadOrInitHiValue(); + void unableToReadOrInitHiValue( @Cause SQLException e ); @LogMessage( level = ERROR ) @Message( value = "Unable to release batch statement..." ) @@ -1425,6 +1575,10 @@ public interface Logger extends BasicLogger { @Message( value = "Could not resolve aggregate function {}; using standard definition" ) void unableToResolveAggregateFunction( String name ); + @LogMessage( level = INFO ) + @Message( value = "Unable to resolve mapping file [%s]" ) + void unableToResolveMappingFile( String xmlFile ); + @LogMessage( level = INFO ) @Message( value = "Unable to retreive cache from JNDI [%s]: %s" ) void unableToRetrieveCache( String namespace, @@ -1446,26 +1600,29 @@ public interface Logger extends BasicLogger { @Message( value = "JTA rollback failed" ) String unableToRollbackJta(); + @LogMessage( level = ERROR ) @Message( value = "Error running schema update" ) - Object unableToRunSchemaUpdate(); + void unableToRunSchemaUpdate( @Cause Exception e ); + @LogMessage( level = ERROR ) @Message( value = "Could not set transaction to rollback only" ) - Object unableToSetTransactionToRollbackOnly(); + void unableToSetTransactionToRollbackOnly( @Cause SystemException e ); @Message( value = "Exception while stopping service" ) - Object unableToStopService(); + Object unableToStopHibernateService(); @LogMessage( level = INFO ) @Message( value = "Error stopping service [%s] : %s" ) - void unableToStopService( Class class1, + void unableToStopService( Class class1, String string ); @LogMessage( level = ERROR ) @Message( value = "Could not synchronize database state with session: %s" ) void unableToSynchronizeDatabaseStateWithSession( HibernateException he ); + @LogMessage( level = ERROR ) @Message( value = "Could not toggle autocommit" ) - Object unableToToggleAutoCommit(); + void unableToToggleAutoCommit( @Cause Exception e ); @LogMessage( level = ERROR ) @Message( value = "Unable to transform class: %s" ) @@ -1477,8 +1634,10 @@ public interface Logger extends BasicLogger { @Message( value = "Could not update hi value in: %s" ) Object unableToUpdateHiValue( String tableName ); + @LogMessage( level = ERROR ) @Message( value = "Could not updateQuery hi value in: %s" ) - Object unableToUpdateQueryHiValue( String tableName ); + void unableToUpdateQueryHiValue( String tableName, + @Cause SQLException error ); @Message( value = "Error wrapping result set" ) Object unableToWrapResultSet(); @@ -1594,10 +1753,18 @@ public interface Logger extends BasicLogger { @Message( value = "Using JDK 1.4 java.sql.Timestamp handling" ) void usingJdk14TimestampHandling(); + @LogMessage( level = ERROR ) + @Message( value = "Don't use old DTDs, read the Hibernate 3.x Migration Guide!" ) + void usingOldDtd(); + @LogMessage( level = INFO ) @Message( value = "Using pre JDK 1.4 java.sql.Timestamp handling" ) void usingPreJdk14TimestampHandling(); + @LogMessage( level = INFO ) + @Message( value = "Using provided datasource" ) + void usingProvidedDataSource(); + @LogMessage( level = INFO ) @Message( value = "Using bytecode reflection optimizer" ) void usingReflectionOptimizer(); @@ -1648,124 +1815,4 @@ public interface Logger extends BasicLogger { @LogMessage( level = INFO ) @Message( value = "Writing generated schema to file: %s" ) void writingGeneratedSchemaToFile( String outputFile ); - - @Message( value = "Could not create proxy factory for:%s" ) - Object unableToCreateProxyFactory( String entityName ); - - @LogMessage( level = WARN ) - @Message( value = "Entity [%s] is abstract-class/interface explicitly mapped as non-abstract; be sure to supply entity-names" ) - void entityMappedAsNonAbstract( String name ); - - @LogMessage( level = INFO ) - @Message( value = "Lazy property fetching available for: %s" ) - void lazyPropertyFetchingAvailable( String name ); - - @LogMessage( level = ERROR ) - @Message( value = "Getters of lazy classes cannot be final: %s.%s" ) - void gettersOfLazyClassesCannotBeFinal( String entityName, - String name ); - - @LogMessage( level = ERROR ) - @Message( value = "Setters of lazy classes cannot be final: %s.%s" ) - void settersOfLazyClassesCannotBeFinal( String entityName, - String name ); - - @LogMessage( level = INFO ) - @Message( value = "No default (no-argument) constructor for class: %s (class must be instantiated by Interceptor)" ) - void noDefaultConstructor( String name ); - - @Message( value = "IOException occurred closing input stream" ) - Object unableToCloseInputStream(); - - @Message( value = "IOException occurred closing output stream" ) - Object unableToCloseOutputStream(); - - @Message( value = "IOException occurred closing stream" ) - Object unableToCloseStream(); - - @LogMessage( level = INFO ) - @Message( value = "Could not locate 'java.sql.NClob' class; assuming JDBC 3" ) - void unableToLocateNClobClass(); - - @LogMessage( level = INFO ) - @Message( value = "java.sql.Types mapped the same code [%d] multiple times; was [%s]; now [%s]" ) - void JavaSqlTypesMappedSameCodeMultipleTimes( int code, - String old, - String name ); - - @LogMessage( level = WARN ) - @Message( value = "Type [%s] defined no registration keys; ignoring" ) - void typeDefinedNoRegistrationKeys( BasicType type ); - - @LogMessage( level = INFO ) - @Message( value = "Type registration [%s] overrides previous : %s" ) - void typeRegistrationOverridesPrevious( String key, - Type old ); - - @Message( value = "Unable to clean up callable statement" ) - Object unableToCleanUpCallableStatement(); - - @Message( value = "Unable to clean up prepared statement" ) - Object unableToCleanUpPreparedStatement(); - - @LogMessage( level = WARN ) - @Message( value = "Scoping types to session factory %s after already scoped %s" ) - void scopingTypesToSessionFactoryAfterAlreadyScoped( SessionFactoryImplementor factory, - SessionFactoryImplementor factory2 ); - - @LogMessage( level = INFO ) - @Message( value = "Could not bind value '%s' to parameter: %d; %s" ) - void unableToBindValueToParameter( String nullSafeToString, - int index, - String message ); - - @LogMessage( level = INFO ) - @Message( value = "Could not read column value from result set: %s; %s" ) - void unableToReadColumnValueFromResultSet( String name, - String message ); - - @LogMessage( level = ERROR ) - @Message( value = "Error parsing XML (%d) : %s" ) - void parsingXmlError( int lineNumber, - String message ); - - @LogMessage( level = ERROR ) - @Message( value = "Warning parsing XML (%d) : %s" ) - void parsingXmlWarning( int lineNumber, - String message ); - - @Message( value = "Unable to locate config file: %s" ) - String unableToLocateConfigFile( String path ); - - @LogMessage( level = WARN ) - @Message( value = "Recognized obsolete hibernate namespace %s. Use namespace %s instead. Refer to Hibernate 3.6 Migration Guide!" ) - void recognizedObsoleteHibernateNamespace( String oldHibernateNamespace, - String hibernateNamespace ); - - @LogMessage( level = ERROR ) - @Message( value = "Don't use old DTDs, read the Hibernate 3.x Migration Guide!" ) - void usingOldDtd(); - - @LogMessage( level = WARN ) - @Message( value = "SQL Error: %d, SQLState: %s" ) - void sqlError( int errorCode, - String sqlState ); - - @Message( value = "Could not clear warnings" ) - Object unableToClearWarnings(); - - @Message( value = "Could not log warnings" ) - Object unableToLogWarnings(); - - @LogMessage( level = ERROR ) - @Message( value = "Error parsing XML: %s(%d) %s" ) - void parsingXmlError( String file, - int lineNumber, - String message ); - - @LogMessage( level = WARN ) - @Message( value = "Warning parsing XML: %s(%d) %s" ) - void parsingXmlWarning( String file, - int lineNumber, - String message ); } diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/Logger.java b/hibernate-core/src/main/java/org/hibernate/bytecode/Logger.java deleted file mode 100644 index 11765567ee..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/Logger.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * - * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing. - * - * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors. - */ -package org.hibernate.bytecode; - -import static org.jboss.logging.Logger.Level.DEBUG; -import static org.jboss.logging.Logger.Level.ERROR; -import static org.jboss.logging.Logger.Level.WARN; -import org.jboss.logging.BasicLogger; -import org.jboss.logging.LogMessage; -import org.jboss.logging.Message; -import org.jboss.logging.MessageLogger; - -/** - * Interface defining messages that may be logged by the outer class - */ -@MessageLogger -public interface Logger extends BasicLogger { - - @LogMessage( level = WARN ) - @Message( value = "Per HHH-5451 support for cglib as a bytecode provider has been deprecated." ) - void deprecated(); - - @LogMessage( level = DEBUG ) - @Message( value = "Enhancing %s" ) - void enhancingClass( String className ); - - @LogMessage( level = DEBUG ) - @Message( value = "reflection optimizer disabled for: %s [%s: %s" ) - void reflectionOptimizerDisabled( String className, - String simpleClassName, - String errorMessage ); - - @LogMessage( level = DEBUG ) - @Message( value = "reflection optimizer disabled for: %s [%s: %s (property %s)" ) - void reflectionOptimizerDisabledForBulkException( String className, - String simpleClassName, - String errorMessage, - String setterName ); - - @LogMessage( level = ERROR ) - @Message( value = "Unable to build enhancement metamodel for %s" ) - void unableToBuildEnhancementMetamodel( String className ); - - @LogMessage( level = ERROR ) - @Message( value = "Unable to read class: %s" ) - void unableToReadClass( String message ); - - @LogMessage( level = ERROR ) - @Message( value = "Unable to transform class: %s" ) - void unableToTransformClass( String message ); -} diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java index fcc1cb418b..9bfcaf32bb 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java @@ -68,6 +68,7 @@ import org.hibernate.EmptyInterceptor; import org.hibernate.HibernateException; import org.hibernate.Interceptor; import org.hibernate.InvalidMappingException; +import org.hibernate.Logger; import org.hibernate.MappingException; import org.hibernate.MappingNotFoundException; import org.hibernate.SessionFactory; @@ -1650,7 +1651,7 @@ public class Configuration implements Serializable { applyMethod.invoke( validator, persistentClazz ); } catch ( Exception e ) { - LOG.unableToApplyConstraints(className, e.getMessage()); + LOG.warn(LOG.unableToApplyConstraints(className), e); } } } @@ -2205,7 +2206,7 @@ public class Configuration implements Serializable { stream.close(); } catch (IOException ioe) { - LOG.unableToCloseInputStream(resourceName, ioe.getMessage()); + LOG.warn(LOG.unableToCloseInputStreamForResource(resourceName), ioe); } } return this; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java index 929a10f9e8..71f464b524 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java @@ -619,7 +619,7 @@ public final class Environment { stream.close(); } catch (IOException ioe){ - LOG.unableToCloseStream(ioe); + LOG.unableToCloseStreamError(ioe); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java b/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java index e27339d47b..e65e75bef7 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java @@ -29,6 +29,7 @@ import java.util.Properties; import org.hibernate.ConnectionReleaseMode; import org.hibernate.EntityMode; import org.hibernate.HibernateException; +import org.hibernate.Logger; import org.hibernate.bytecode.BytecodeProvider; import org.hibernate.cache.QueryCacheFactory; import org.hibernate.cache.RegionFactory; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java index 7ec2e81187..7addf1bb72 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java @@ -44,6 +44,7 @@ import javax.validation.metadata.ConstraintDescriptor; import javax.validation.metadata.PropertyDescriptor; import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; +import org.hibernate.Logger; import org.hibernate.MappingException; import org.hibernate.event.EventListeners; import org.hibernate.event.PreDeleteEventListener; @@ -125,7 +126,7 @@ class TypeSafeActivator { applyDDL( "", persistentClass, clazz, factory, groups, true ); } catch (Exception e) { - LOG.unableToApplyConstraints(className, e.getMessage()); + LOG.warn(LOG.unableToApplyConstraints(className), e); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java b/hibernate-core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java deleted file mode 100644 index 4e2a2bda69..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.connection; - -import static org.jboss.logging.Logger.Level.ERROR; -import static org.jboss.logging.Logger.Level.INFO; -import static org.jboss.logging.Logger.Level.WARN; -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import org.hibernate.HibernateException; -import org.hibernate.cfg.Environment; -import org.hibernate.util.ReflectHelper; -import org.jboss.logging.BasicLogger; -import org.jboss.logging.LogMessage; -import org.jboss.logging.Message; -import org.jboss.logging.MessageLogger; - -/** - * Instantiates a connection provider given either System properties or - * a java.util.Properties instance. The ConnectionProviderFactory - * first attempts to find a name of a ConnectionProvider subclass in the - * property hibernate.connection.provider_class. If missing, heuristics are used - * to choose either DriverManagerConnectionProvider, - * DatasourceConnectionProvider, C3P0ConnectionProvider or - * DBCPConnectionProvider. - * - * @author Gavin King - * @see ConnectionProvider - */ - -public final class ConnectionProviderFactory { - - private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, - ConnectionProviderFactory.class.getPackage().getName()); - - /** - * Instantiate a ConnectionProvider using System properties. - * - * @return The created connection provider. - * - * @throws HibernateException - */ - public static ConnectionProvider newConnectionProvider() throws HibernateException { - return newConnectionProvider( Environment.getProperties() ); - } - - /** - * Instantiate a ConnectionProvider using given properties. - * Method newConnectionProvider. - * - * @param properties hibernate SessionFactory properties - * - * @return ConnectionProvider - * - * @throws HibernateException - */ - public static ConnectionProvider newConnectionProvider(Properties properties) throws HibernateException { - return newConnectionProvider( properties, null ); - } - - /** - * Create a connection provider based on the given information. - * - * @param properties Properties being used to build the {@link org.hibernate.SessionFactory}. - * @param connectionProviderInjectionData Something to be injected in the connection provided - * - * @return The created connection provider - * - * @throws HibernateException - */ - public static ConnectionProvider newConnectionProvider(Properties properties, Map connectionProviderInjectionData) - throws HibernateException { - ConnectionProvider connections; - String providerClass = properties.getProperty( Environment.CONNECTION_PROVIDER ); - if ( providerClass != null ) { - connections = initializeConnectionProviderFromConfig( providerClass ); - } - else if ( c3p0ConfigDefined( properties ) && c3p0ProviderPresent() ) { - connections = initializeConnectionProviderFromConfig("org.hibernate.connection.C3P0ConnectionProvider"); - } - else if ( properties.getProperty( Environment.DATASOURCE ) != null ) { - connections = new DatasourceConnectionProvider(); - } - else if ( properties.getProperty( Environment.URL ) != null ) { - connections = new DriverManagerConnectionProvider(); - } - else { - connections = new UserSuppliedConnectionProvider(); - } - - if ( connectionProviderInjectionData != null && connectionProviderInjectionData.size() != 0 ) { - //inject the data - try { - BeanInfo info = Introspector.getBeanInfo( connections.getClass() ); - PropertyDescriptor[] descritors = info.getPropertyDescriptors(); - int size = descritors.length; - for ( int index = 0; index < size; index++ ) { - String propertyName = descritors[index].getName(); - if ( connectionProviderInjectionData.containsKey( propertyName ) ) { - Method method = descritors[index].getWriteMethod(); - method.invoke( - connections, new Object[] { connectionProviderInjectionData.get( propertyName ) } - ); - } - } - } - catch ( IntrospectionException e ) { - throw new HibernateException( "Unable to inject objects into the connection provider", e ); - } - catch ( IllegalAccessException e ) { - throw new HibernateException( "Unable to inject objects into the connection provider", e ); - } - catch ( InvocationTargetException e ) { - throw new HibernateException( "Unable to inject objects into the connection provider", e ); - } - } - connections.configure( properties ); - return connections; - } - - private static boolean c3p0ProviderPresent() { - try { - ReflectHelper.classForName( "org.hibernate.connection.C3P0ConnectionProvider" ); - } - catch ( ClassNotFoundException e ) { - LOG.c3p0PropertiesIgnored(); - return false; - } - return true; - } - - private static boolean c3p0ConfigDefined(Properties properties) { - Iterator iter = properties.keySet().iterator(); - while ( iter.hasNext() ) { - String property = (String) iter.next(); - if ( property.startsWith( "hibernate.c3p0" ) ) { - return true; - } - } - return false; - } - - private static ConnectionProvider initializeConnectionProviderFromConfig(String providerClass) { - ConnectionProvider connections; - try { - LOG.initializingConnectionProvider(providerClass); - connections = (ConnectionProvider) ReflectHelper.classForName( providerClass ).newInstance(); - } - catch ( Exception e ) { - LOG.unableToInstantiateConnectionProvider(e.getMessage()); - throw new HibernateException( "Could not instantiate connection provider: " + providerClass ); - } - return connections; - } - - // cannot be instantiated - - private ConnectionProviderFactory() { - throw new UnsupportedOperationException(); - } - - /** - * Transform JDBC connection properties. - * - * Passed in the form hibernate.connection.* to the - * format accepted by DriverManager by trimming the leading "hibernate.connection". - */ - public static Properties getConnectionProperties(Properties properties) { - - Iterator iter = properties.keySet().iterator(); - Properties result = new Properties(); - while ( iter.hasNext() ) { - String prop = (String) iter.next(); - if ( prop.startsWith( Environment.CONNECTION_PREFIX ) && !SPECIAL_PROPERTIES.contains( prop ) ) { - result.setProperty( - prop.substring( Environment.CONNECTION_PREFIX.length() + 1 ), - properties.getProperty( prop ) - ); - } - } - String userName = properties.getProperty( Environment.USER ); - if ( userName != null ) { - result.setProperty( "user", userName ); - } - return result; - } - - private static final Set SPECIAL_PROPERTIES; - - static { - SPECIAL_PROPERTIES = new HashSet(); - SPECIAL_PROPERTIES.add( Environment.DATASOURCE ); - SPECIAL_PROPERTIES.add( Environment.URL ); - SPECIAL_PROPERTIES.add( Environment.CONNECTION_PROVIDER ); - SPECIAL_PROPERTIES.add( Environment.POOL_SIZE ); - SPECIAL_PROPERTIES.add( Environment.ISOLATION ); - SPECIAL_PROPERTIES.add( Environment.DRIVER ); - SPECIAL_PROPERTIES.add( Environment.USER ); - - } - - /** - * Interface defining messages that may be logged by the outer class - */ - @MessageLogger - interface Logger extends BasicLogger { - - @LogMessage( level = WARN ) - @Message( value = "c3p0 properties is specified, but could not find org.hibernate.connection.C3P0ConnectionProvider from the classpath, these properties are going to be ignored." ) - void c3p0PropertiesIgnored(); - - @LogMessage( level = INFO ) - @Message( value = "Initializing connection provider: %s" ) - void initializingConnectionProvider( String providerClass ); - - @LogMessage( level = ERROR ) - @Message( value = "Could not instantiate connection provider\n%s" ) - void unableToInstantiateConnectionProvider( String message ); - } -} - - - - - - diff --git a/hibernate-core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java b/hibernate-core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java deleted file mode 100644 index d4184c6fca..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - * - */ -package org.hibernate.connection; - -import static org.jboss.logging.Logger.Level.ERROR; -import static org.jboss.logging.Logger.Level.INFO; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.Properties; -import javax.sql.DataSource; -import org.hibernate.HibernateException; -import org.hibernate.cfg.Environment; -import org.hibernate.internal.util.jndi.JndiHelper; -import org.jboss.logging.BasicLogger; -import org.jboss.logging.LogMessage; -import org.jboss.logging.Message; -import org.jboss.logging.MessageLogger; - -/** - * A connection provider that uses a DataSource registered with JNDI. - * Hibernate will use this ConnectionProvider by default if the - * property hibernate.connection.datasource is set. - * @see ConnectionProvider - * @author Gavin King - */ -public class DatasourceConnectionProvider implements ConnectionProvider { - private DataSource ds; - private String user; - private String pass; - - private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, - DatasourceConnectionProvider.class.getPackage().getName()); - - public DataSource getDataSource() { - return ds; - } - - public void setDataSource(DataSource ds) { - this.ds = ds; - } - - public void configure(Properties props) throws HibernateException { - - String jndiName = props.getProperty( Environment.DATASOURCE ); - if ( jndiName == null ) { - String msg = "datasource JNDI name was not specified by property " + Environment.DATASOURCE; - LOG.unspecifiedJndiName(msg); - throw new HibernateException( msg ); - } - - user = props.getProperty( Environment.USER ); - pass = props.getProperty( Environment.PASS ); - - try { - ds = ( DataSource ) JndiHelper.getInitialContext( props ).lookup( jndiName ); - } - catch ( Exception e ) { - LOG.datasourceNotFound(jndiName, e.getMessage()); - throw new HibernateException( "Could not find datasource", e ); - } - if ( ds == null ) { - throw new HibernateException( "Could not find datasource: " + jndiName ); - } - LOG.usingDatasource(jndiName); - } - - public Connection getConnection() throws SQLException { - if (user != null || pass != null) { - return ds.getConnection(user, pass); - } - else { - return ds.getConnection(); - } - } - - public void closeConnection(Connection conn) throws SQLException { - conn.close(); - } - - public void close() {} - - /** - * @see ConnectionProvider#supportsAggressiveRelease() - */ - public boolean supportsAggressiveRelease() { - return true; - } - - /** - * Interface defining messages that may be logged by the outer class - */ - @MessageLogger - interface Logger extends BasicLogger { - - @LogMessage( level = ERROR ) - @Message( value = "Could not find datasource: %s\n%s" ) - void datasourceNotFound( String jndiName, - String message ); - - @LogMessage( level = ERROR ) - @Message( value = "%s" ) - void unspecifiedJndiName( String msg ); - - @LogMessage( level = INFO ) - @Message( value = "Using datasource: %s" ) - void usingDatasource( String jndiName ); - } -} \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java b/hibernate-core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java deleted file mode 100644 index dc015e3c8d..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - * - */ -package org.hibernate.connection; - -import static org.jboss.logging.Logger.Level.DEBUG; -import static org.jboss.logging.Logger.Level.ERROR; -import static org.jboss.logging.Logger.Level.INFO; -import static org.jboss.logging.Logger.Level.TRACE; -import static org.jboss.logging.Logger.Level.WARN; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Properties; -import org.hibernate.HibernateException; -import org.hibernate.cfg.Environment; -import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.util.ReflectHelper; -import org.jboss.logging.BasicLogger; -import org.jboss.logging.LogMessage; -import org.jboss.logging.Message; -import org.jboss.logging.MessageLogger; - -/** - * A connection provider that uses java.sql.DriverManager. This provider - * also implements a very rudimentary connection pool. - * @see ConnectionProvider - * @author Gavin King - */ -public class DriverManagerConnectionProvider implements ConnectionProvider { - - private String url; - private Properties connectionProps; - private Integer isolation; - private final ArrayList pool = new ArrayList(); - private int poolSize; - private int checkedOut = 0; - private boolean autocommit; - - private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, - DriverManagerConnectionProvider.class.getPackage().getName()); - - public void configure(Properties props) throws HibernateException { - - String driverClass = props.getProperty(Environment.DRIVER); - - poolSize = ConfigurationHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20 - LOG.usingHibernateConnectionPool(); - LOG.hibernateConnectionPoolSize(poolSize); - - autocommit = ConfigurationHelper.getBoolean(Environment.AUTOCOMMIT, props); - LOG.autocommmitMode(autocommit); - - isolation = ConfigurationHelper.getInteger(Environment.ISOLATION, props); - if (isolation!=null) - LOG.jdbcIsolationLevel(Environment.isolationLevelToString(isolation.intValue())); - - if (driverClass == null) LOG.unspecifiedJdbcDriver(Environment.DRIVER); - else { - try { - // trying via forName() first to be as close to DriverManager's semantics - Class.forName(driverClass); - } - catch (ClassNotFoundException cnfe) { - try { - ReflectHelper.classForName(driverClass); - } - catch (ClassNotFoundException e) { - String msg = "JDBC Driver class not found: " + driverClass; - LOG.jdbcDriverClassNotFound(msg, e.getMessage()); - throw new HibernateException(msg, e); - } - } - } - - url = props.getProperty( Environment.URL ); - if ( url == null ) { - String msg = "JDBC URL was not specified by property " + Environment.URL; - LOG.unspecifiedJdbcUrl(msg); - throw new HibernateException( msg ); - } - - connectionProps = ConnectionProviderFactory.getConnectionProperties( props ); - - LOG.usingDriver(driverClass, url); - // if debug level is enabled, then log the password, otherwise mask it - if (LOG.isDebugEnabled()) LOG.connectionProperties(connectionProps); - else LOG.connectionProperties(ConfigurationHelper.maskOut(connectionProps, "password")); - } - - public Connection getConnection() throws SQLException { - - LOG.checkedOutConnections(checkedOut); - - synchronized (pool) { - if ( !pool.isEmpty() ) { - int last = pool.size() - 1; - if (LOG.isTraceEnabled()) { - LOG.usingPooledJdbcConnection(last); - checkedOut++; - } - Connection pooled = (Connection) pool.remove(last); - if (isolation!=null) pooled.setTransactionIsolation( isolation.intValue() ); - if ( pooled.getAutoCommit()!=autocommit ) pooled.setAutoCommit(autocommit); - return pooled; - } - } - - LOG.openingNewJdbcConnection(); - Connection conn = DriverManager.getConnection(url, connectionProps); - if (isolation!=null) conn.setTransactionIsolation( isolation.intValue() ); - if ( conn.getAutoCommit()!=autocommit ) conn.setAutoCommit(autocommit); - - LOG.createdConnection(url, conn.getTransactionIsolation()); - if (LOG.isTraceEnabled()) checkedOut++; - - return conn; - } - - public void closeConnection(Connection conn) throws SQLException { - - if (LOG.isDebugEnabled()) checkedOut--; - - synchronized (pool) { - int currentSize = pool.size(); - if ( currentSize < poolSize ) { - LOG.returningConnectionToPool(currentSize + 1); - pool.add(conn); - return; - } - } - - LOG.closingJdbcConnection(); - - conn.close(); - - } - - @Override - protected void finalize() { - close(); - } - - public void close() { - - LOG.cleaningConnectionPool(url); - - Iterator iter = pool.iterator(); - while ( iter.hasNext() ) { - try { - ( (Connection) iter.next() ).close(); - } - catch (SQLException sqle) { - LOG.unableToClosePooledConnection(sqle.getMessage()); - } - } - pool.clear(); - - } - - /** - * @see ConnectionProvider#supportsAggressiveRelease() - */ - public boolean supportsAggressiveRelease() { - return false; - } - - /** - * Interface defining messages that may be logged by the outer class - */ - @MessageLogger - interface Logger extends BasicLogger { - - @LogMessage( level = INFO ) - @Message( value = "Autocommit mode: %s" ) - void autocommmitMode( boolean autocommit ); - - @LogMessage( level = TRACE ) - @Message( value = "Total checked-out connections: %d" ) - void checkedOutConnections( int checkedOut ); - - @LogMessage( level = INFO ) - @Message( value = "Cleaning up connection pool: %s" ) - void cleaningConnectionPool( String url ); - - @LogMessage( level = DEBUG ) - @Message( value = "Closing JDBC connection" ) - void closingJdbcConnection(); - - @LogMessage( level = INFO ) - @Message( value = "Connection properties: %s" ) - void connectionProperties( Properties connectionProps ); - - @LogMessage( level = DEBUG ) - @Message( value = "Created connection to: %s, Isolation Level: %d" ) - void createdConnection( String url, - int transactionIsolation ); - - @LogMessage( level = INFO ) - @Message( value = "Hibernate connection pool size: %s" ) - void hibernateConnectionPoolSize( int poolSize ); - - @LogMessage( level = ERROR ) - @Message( value = "%s\n%s" ) - void jdbcDriverClassNotFound( String message, - String errorMessage ); - - @LogMessage( level = INFO ) - @Message( value = "JDBC isolation level: %s" ) - void jdbcIsolationLevel( String isolationLevelToString ); - - @LogMessage( level = DEBUG ) - @Message( value = "Opening new JDBC connection" ) - void openingNewJdbcConnection(); - - @LogMessage( level = TRACE ) - @Message( value = "Returning connection to pool, pool size: %d" ) - void returningConnectionToPool( int i ); - - @LogMessage( level = WARN ) - @Message( value = "Problem closing pooled connection\n%s" ) - void unableToClosePooledConnection( String message ); - - @LogMessage( level = WARN ) - @Message( value = "No JDBC Driver class was specified by property %s" ) - void unspecifiedJdbcDriver( String driver ); - - @LogMessage( level = ERROR ) - @Message( value = "%s" ) - void unspecifiedJdbcUrl( String message ); - - @LogMessage( level = INFO ) - @Message( value = "Using driver: %s at URL: %s" ) - void usingDriver( String driverClass, - String url ); - - @LogMessage( level = INFO ) - @Message( value = "Using Hibernate built-in connection pool (not for production use!)" ) - void usingHibernateConnectionPool(); - - @LogMessage( level = TRACE ) - @Message( value = "Using pooled JDBC connection, pool size: %d" ) - void usingPooledJdbcConnection( int last ); - } -} - - - - - - - diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/resolver/AbstractDialectResolver.java b/hibernate-core/src/main/java/org/hibernate/dialect/resolver/AbstractDialectResolver.java deleted file mode 100644 index 126be42612..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/dialect/resolver/AbstractDialectResolver.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.dialect.resolver; - -import java.sql.DatabaseMetaData; -import java.sql.SQLException; -import org.hibernate.JDBCException; -import org.hibernate.cfg.CollectionSecondPass; -import org.hibernate.dialect.Dialect; -import org.hibernate.exception.JDBCConnectionException; -import org.hibernate.service.jdbc.dialect.spi.DialectResolver; - -/** - * A templated resolver impl which delegates to the {@link #resolveDialectInternal} method - * and handles any thrown {@link SQLException}s. - * - * @author Steve Ebersole - */ -public abstract class AbstractDialectResolver implements DialectResolver { - - private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, - CollectionSecondPass.class.getPackage().getName()); - - /** - * {@inheritDoc} - *

- * Here we template the resolution, delegating to {@link #resolveDialectInternal} and handling - * {@link java.sql.SQLException}s properly. - */ - public final Dialect resolveDialect(DatabaseMetaData metaData) { - try { - return resolveDialectInternal( metaData ); - } - catch ( SQLException sqlException ) { - JDBCException jdbcException = BasicSQLExceptionConverter.INSTANCE.convert( sqlException ); - if (jdbcException instanceof JDBCConnectionException) throw jdbcException; - LOG.unableToQueryDatabaseMetadata(BasicSQLExceptionConverter.MSG, sqlException.getMessage()); - return null; - } - catch ( Throwable t ) { - LOG.unableToExecuteResolver(this, t.getMessage()); - return null; - } - } - - /** - * Perform the actual resolution without caring about handling {@link SQLException}s. - * - * @param metaData The database metadata - * @return The resolved dialect, or null if we could not resolve. - * @throws SQLException Indicates problems accessing the metadata. - */ - protected abstract Dialect resolveDialectInternal(DatabaseMetaData metaData) throws SQLException; -} diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/resolver/DialectFactory.java b/hibernate-core/src/main/java/org/hibernate/dialect/resolver/DialectFactory.java deleted file mode 100644 index d0be9c4b16..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/dialect/resolver/DialectFactory.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.dialect.resolver; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; -import java.util.Properties; -import org.hibernate.HibernateException; -import org.hibernate.Logger; -import org.hibernate.cfg.Environment; -import org.hibernate.dialect.Dialect; -import org.hibernate.util.ReflectHelper; - -/** - * A factory for generating Dialect instances. - * - * @author Steve Ebersole - * @author Tomoto Shimizu Washio - */ -public class DialectFactory { - - private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, - DialectFactory.class.getPackage().getName()); - - private static DialectResolverSet DIALECT_RESOLVERS = new DialectResolverSet(); - - static { - // register the standard dialect resolver - DIALECT_RESOLVERS.addResolver( new StandardDialectResolver() ); - - // register resolvers set via Environment property - String userSpecifedResolverSetting = Environment.getProperties().getProperty( Environment.DIALECT_RESOLVERS ); - if ( userSpecifedResolverSetting != null ) { - String[] userSpecifedResolvers = userSpecifedResolverSetting.split( "\\s+" ); - for ( int i = 0; i < userSpecifedResolvers.length; i++ ) { - registerDialectResolver( userSpecifedResolvers[i] ); - } - } - } - - /*package*/ static void registerDialectResolver(String resolverName) { - try { - DialectResolver resolver = ( DialectResolver ) ReflectHelper.classForName( resolverName ).newInstance(); - DIALECT_RESOLVERS.addResolverAtFirst( resolver ); - } - catch ( ClassNotFoundException cnfe ) { - LOG.dialectResolverNotFound(resolverName); - } - catch ( Exception e ) { - LOG.unableToInstantiateDialectResolver(e.getMessage()); - } - } - - /** - * Builds an appropriate Dialect instance. - *

- * If a dialect is explicitly named in the incoming properties, it is used. Otherwise, it is - * determined by dialect resolvers based on the passed connection. - *

- * An exception is thrown if a dialect was not explicitly set and no resolver could make - * the determination from the given connection. - * - * @param properties The configuration properties. - * @param connection The configured connection. - * @return The appropriate dialect instance. - * @throws HibernateException No dialect specified and no resolver could make the determination. - */ - public static Dialect buildDialect(Properties properties, Connection connection) throws HibernateException { - String dialectName = properties.getProperty( Environment.DIALECT ); - if ( dialectName == null ) { - return determineDialect( connection ); - } - else { - return constructDialect( dialectName ); - } - } - - public static Dialect buildDialect(Properties properties) { - String dialectName = properties.getProperty( Environment.DIALECT ); - if ( dialectName == null ) { - throw new HibernateException( "'hibernate.dialect' must be set when no Connection available" ); - } - return constructDialect( dialectName ); - } - - /** - * Determine the appropriate Dialect to use given the connection. - * - * @param connection The configured connection. - * @return The appropriate dialect instance. - * - * @throws HibernateException No connection given or no resolver could make - * the determination from the given connection. - */ - private static Dialect determineDialect(Connection connection) { - if ( connection == null ) { - throw new HibernateException( "Connection cannot be null when 'hibernate.dialect' not set" ); - } - - try { - final DatabaseMetaData databaseMetaData = connection.getMetaData(); - final Dialect dialect = DIALECT_RESOLVERS.resolveDialect( databaseMetaData ); - - if ( dialect == null ) { - throw new HibernateException( - "Unable to determine Dialect to use [name=" + databaseMetaData.getDatabaseProductName() + - ", majorVersion=" + databaseMetaData.getDatabaseMajorVersion() + - "]; user must register resolver or explicitly set 'hibernate.dialect'" - ); - } - - return dialect; - } - catch ( SQLException sqlException ) { - throw new HibernateException( - "Unable to access java.sql.DatabaseMetaData to determine appropriate Dialect to use", - sqlException - ); - } - } - - /** - * Returns a dialect instance given the name of the class to use. - * - * @param dialectName The name of the dialect class. - * - * @return The dialect instance. - */ - public static Dialect constructDialect(String dialectName) { - try { - return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance(); - } - catch ( ClassNotFoundException cnfe ) { - throw new HibernateException( "Dialect class not found: " + dialectName, cnfe ); - } - catch ( Exception e ) { - throw new HibernateException( "Could not instantiate dialect class", e ); - } - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/resolver/DialectResolverSet.java b/hibernate-core/src/main/java/org/hibernate/dialect/resolver/DialectResolverSet.java deleted file mode 100644 index 24b9a96e0b..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/dialect/resolver/DialectResolverSet.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.dialect.resolver; - -import java.sql.DatabaseMetaData; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.hibernate.cfg.CollectionSecondPass; -import org.hibernate.dialect.Dialect; -import org.hibernate.exception.JDBCConnectionException; -import org.hibernate.service.jdbc.dialect.spi.DialectResolver; - -/** - * A {@link DialectResolver} implementation which coordinates resolution by delegating to its - * registered sub-resolvers. Sub-resolvers may be registered by calling either {@link #addResolver} or - * {@link #addResolverAtFirst}. - * - * @author Tomoto Shimizu Washio - */ -public class DialectResolverSet implements DialectResolver { - - private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, - CollectionSecondPass.class.getPackage().getName()); - - private List resolvers = new ArrayList(); - - /** - * {@inheritDoc} - */ - public Dialect resolveDialect(DatabaseMetaData metaData) { - Iterator i = resolvers.iterator(); - while ( i.hasNext() ) { - final DialectResolver resolver = ( DialectResolver ) i.next(); - try { - Dialect dialect = resolver.resolveDialect( metaData ); - if ( dialect != null ) { - return dialect; - } - } - catch ( JDBCConnectionException e ) { - throw e; - } - catch ( Throwable t ) { - LOG.subResolverException(t.getMessage()); - } - } - return null; - } - - /** - * Add a resolver at the end of the underlying resolver list. The resolver added by this method is at lower - * priority than any other existing resolvers. - * - * @param resolver The resolver to add. - */ - public void addResolver(DialectResolver resolver) { - resolvers.add( resolver ); - } - - /** - * Add a resolver at the beginning of the underlying resolver list. The resolver added by this method is at higher - * priority than any other existing resolvers. - * - * @param resolver The resolver to add. - */ - public void addResolverAtFirst(DialectResolver resolver) { - resolvers.add( 0, resolver ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/resolver/StandardDialectResolver.java b/hibernate-core/src/main/java/org/hibernate/dialect/resolver/StandardDialectResolver.java deleted file mode 100644 index a90a4c8c71..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/dialect/resolver/StandardDialectResolver.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.dialect.resolver; - -import java.sql.DatabaseMetaData; -import java.sql.SQLException; -import org.hibernate.Logger; -import org.hibernate.dialect.DB2Dialect; -import org.hibernate.dialect.DerbyDialect; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.H2Dialect; -import org.hibernate.dialect.HSQLDialect; -import org.hibernate.dialect.InformixDialect; -import org.hibernate.dialect.Ingres10Dialect; -import org.hibernate.dialect.Ingres9Dialect; -import org.hibernate.dialect.IngresDialect; -import org.hibernate.dialect.MySQLDialect; -import org.hibernate.dialect.Oracle10gDialect; -import org.hibernate.dialect.Oracle8iDialect; -import org.hibernate.dialect.Oracle9iDialect; -import org.hibernate.dialect.PostgreSQLDialect; -import org.hibernate.dialect.SQLServerDialect; -import org.hibernate.dialect.SybaseASE15Dialect; -import org.hibernate.dialect.SybaseAnywhereDialect; - -/** - * The standard Hibernate resolver. - * - * @author Steve Ebersole - */ -public class StandardDialectResolver extends AbstractDialectResolver{ - - private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, - StandardDialectResolver.class.getPackage().getName()); - - @Override - protected Dialect resolveDialectInternal(DatabaseMetaData metaData) throws SQLException { - String databaseName = metaData.getDatabaseProductName(); - int databaseMajorVersion = metaData.getDatabaseMajorVersion(); - - if ( "HSQL Database Engine".equals( databaseName ) ) { - return new HSQLDialect(); - } - - if ( "H2".equals( databaseName ) ) { - return new H2Dialect(); - } - - if ( "MySQL".equals( databaseName ) ) { - return new MySQLDialect(); - } - - if ( "PostgreSQL".equals( databaseName ) ) { - return new PostgreSQLDialect(); - } - - if ( "Apache Derby".equals( databaseName ) ) { - return new DerbyDialect(); - } - - if ( "ingres".equalsIgnoreCase( databaseName ) ) { - switch( databaseMajorVersion ) { - case 9: - int databaseMinorVersion = metaData.getDatabaseMinorVersion(); - if (databaseMinorVersion > 2) { - return new Ingres9Dialect(); - } - return new IngresDialect(); - case 10: - LOG.unsupportedIngresVersion(); - return new Ingres10Dialect(); - default: - LOG.unknownIngresVersion(databaseMajorVersion); - } - return new IngresDialect(); - } - - if ( databaseName.startsWith( "Microsoft SQL Server" ) ) { - return new SQLServerDialect(); - } - - if ( "Sybase SQL Server".equals( databaseName ) || "Adaptive Server Enterprise".equals( databaseName ) ) { - return new SybaseASE15Dialect(); - } - - if ( databaseName.startsWith( "Adaptive Server Anywhere" ) ) { - return new SybaseAnywhereDialect(); - } - - if ( "Informix Dynamic Server".equals( databaseName ) ) { - return new InformixDialect(); - } - - if ( databaseName.startsWith( "DB2/" ) ) { - return new DB2Dialect(); - } - - if ( "Oracle".equals( databaseName ) ) { - switch ( databaseMajorVersion ) { - case 11: - LOG.unsupportedOracleVersion(); - return new Oracle10gDialect(); - case 10: - return new Oracle10gDialect(); - case 9: - return new Oracle9iDialect(); - case 8: - return new Oracle8iDialect(); - default: - LOG.unknownOracleVersion(databaseMajorVersion); - } - } - - return null; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java index 03eae474f5..5ff012c8e5 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java @@ -27,6 +27,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import org.hibernate.Logger; import org.hibernate.engine.jdbc.batch.spi.Batch; import org.hibernate.engine.jdbc.batch.spi.BatchObserver; import org.hibernate.engine.jdbc.spi.SQLExceptionHelper; @@ -120,7 +121,7 @@ public abstract class AbstractBatchImpl implements Batch { if ( statement != null ) { LOG.debug("Reusing prepared statement"); statementLogger.logStatement( sql ); - } + } return statement; } @@ -131,12 +132,8 @@ public abstract class AbstractBatchImpl implements Batch { @Override public void addBatchStatement(Object key, String sql, PreparedStatement preparedStatement) { checkConsistentBatchKey( key ); - if ( sql == null ) { - throw new IllegalArgumentException( "sql must be non-null." ); - } - if ( statements.put( sql, preparedStatement ) != null ) { - log.error( "PreparedStatement was already in the batch, [" + sql + "]." ); - } + if (sql == null) throw new IllegalArgumentException("sql must be non-null."); + if (statements.put(sql, preparedStatement) != null) LOG.preparedStatementAlreadyInBatch(sql); } protected void checkConsistentBatchKey(Object key) { @@ -175,7 +172,7 @@ public abstract class AbstractBatchImpl implements Batch { } catch ( SQLException e ) { LOG.unableToReleaseBatchStatement(); - LOG.sqlExceptionEscapedProxy(e.getMessage()); + LOG.sqlExceptionEscapedProxy(e); } } getStatements().clear(); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilder.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilder.java index 70d63205f2..cb1fd90431 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilder.java @@ -23,6 +23,7 @@ */ package org.hibernate.engine.jdbc.batch.internal; +import org.hibernate.Logger; import org.hibernate.engine.jdbc.batch.spi.Batch; import org.hibernate.engine.jdbc.spi.SQLExceptionHelper; import org.hibernate.engine.jdbc.spi.SQLStatementLogger; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchingBatch.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchingBatch.java index 8464160c33..da7f7ea33e 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchingBatch.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchingBatch.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Map; import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; +import org.hibernate.Logger; import org.hibernate.engine.jdbc.spi.SQLExceptionHelper; import org.hibernate.engine.jdbc.spi.SQLStatementLogger; import org.hibernate.jdbc.Expectation; @@ -81,7 +82,7 @@ public class BatchingBatch extends AbstractBatchImpl { statement.addBatch(); } catch ( SQLException e ) { - LOG.error( LOG.sqlExceptionEscapedProxy(), e ); + LOG.sqlExceptionEscapedProxy(e); throw getSqlExceptionHelper().convert( e, "could not perform addBatch", sql ); } List expectations = expectationsBySql.get( sql ); @@ -152,7 +153,7 @@ public class BatchingBatch extends AbstractBatchImpl { checkRowCounts( sql, ps.executeBatch(), ps, expectations ); } catch ( SQLException e ) { - log.error( "sqlexception escaped proxy", e ); + LOG.sqlExceptionEscapedProxy(e); throw getSqlExceptionHelper() .convert( e, "could not execute statement: " + sql ); } @@ -160,16 +161,14 @@ public class BatchingBatch extends AbstractBatchImpl { private void checkRowCounts(String sql, int[] rowCounts, PreparedStatement ps, List expectations) { int numberOfRowCounts = rowCounts.length; - if ( numberOfRowCounts != expectations.size() ) { - log.warn( "JDBC driver did not return the expected number of row counts" ); - } + if (numberOfRowCounts != expectations.size()) LOG.unexpectedRowCounts(); try { for ( int i = 0; i < numberOfRowCounts; i++ ) { expectations.get( i ).verifyOutcome( rowCounts[i], ps, i ); } } catch ( SQLException e ) { - log.error( "sqlexception escaped proxy", e ); + LOG.sqlExceptionEscapedProxy(e); throw getSqlExceptionHelper() .convert( e, "row count verification failed for statement: ", sql ); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/Logger.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/Logger.java deleted file mode 100644 index 06b4eaebc7..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/Logger.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * - * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing. - * - * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors. - */ -package org.hibernate.engine.jdbc.batch.internal; - -import static org.jboss.logging.Logger.Level.DEBUG; -import static org.jboss.logging.Logger.Level.ERROR; -import static org.jboss.logging.Logger.Level.INFO; -import static org.jboss.logging.Logger.Level.TRACE; -import static org.jboss.logging.Logger.Level.WARN; -import org.jboss.logging.BasicLogger; -import org.jboss.logging.LogMessage; -import org.jboss.logging.Message; -import org.jboss.logging.MessageLogger; - -/** - * Interface defining messages that may be logged by the outer class - */ -@MessageLogger -interface Logger extends BasicLogger { - - @LogMessage( level = INFO ) - @Message( value = "On release of batch it still contained JDBC statements" ) - void batchContainedStatementsOnRelease(); - - @LogMessage( level = TRACE ) - @Message( value = "building batch [size=%d]" ) - void buildingBatch( int size ); - - @LogMessage( level = DEBUG ) - @Message( value = "Executing batch size: %d" ) - void executingBatchSize( int batchPosition ); - - @LogMessage( level = DEBUG ) - @Message( value = "No batched statements to execute" ) - void noBatchesToExecute(); - - @LogMessage( level = DEBUG ) - @Message( value = "Reusing batch statement" ) - void reusingBatchStatement(); - - @LogMessage( level = ERROR ) - @Message( value = "SqlException escaped proxy : %s" ) - void sqlExceptionEscapedProxy( String message ); - - @LogMessage( level = ERROR ) - @Message( value = "Exception executing batch [%s]" ) - void unableToExecuteBatch( String message ); - - @LogMessage( level = ERROR ) - @Message( value = "Unable to release batch statement..." ) - void unableToReleaseBatchStatement(); - - @LogMessage( level = WARN ) - @Message( value = "JDBC driver did not return the expected number of row counts" ) - void unexpectedRowCounts(); -} diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/NonBatchingBatch.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/NonBatchingBatch.java index b5aef5d319..1099cd0010 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/NonBatchingBatch.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/NonBatchingBatch.java @@ -59,7 +59,7 @@ public class NonBatchingBatch extends AbstractBatchImpl { expectation.verifyOutcome( rowCount, statement, 0 ); } catch ( SQLException e ) { - log.error( "sqlexception escaped proxy", e ); + LOG.sqlExceptionEscapedProxy(e); throw getSqlExceptionHelper().convert( e, "could not execute batch statement", sql ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JDBCContextImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JDBCContextImpl.java index 6584bb7c5a..75b99f933f 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JDBCContextImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JDBCContextImpl.java @@ -27,7 +27,6 @@ package org.hibernate.engine.jdbc.internal; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; import javax.transaction.TransactionManager; @@ -38,6 +37,7 @@ import org.hibernate.Logger; import org.hibernate.SessionException; import org.hibernate.Transaction; import org.hibernate.TransactionException; +import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.jdbc.spi.ConnectionManager; import org.hibernate.engine.jdbc.spi.JDBCContext; import org.hibernate.transaction.synchronization.CallbackCoordinator; @@ -144,12 +144,6 @@ public class JDBCContextImpl implements ConnectionManagerImpl.Callback, JDBCCont public Connection borrowConnection() { return connectionManager.borrowConnection(); } - - @Override - public Connection connection() throws HibernateException { - if ( owner.isClosed() ) { - throw new SessionException( "Session is closed" ); - } public Connection connection() throws HibernateException { if (owner.isClosed()) throw new SessionException("Session is closed"); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcResourceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcResourceRegistryImpl.java index 2705202ee2..e8a3d38d39 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcResourceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcResourceRegistryImpl.java @@ -31,6 +31,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import org.hibernate.HibernateException; +import org.hibernate.Logger; import org.hibernate.engine.jdbc.spi.InvalidatableWrapper; import org.hibernate.engine.jdbc.spi.JdbcResourceRegistry; import org.hibernate.engine.jdbc.spi.JdbcWrapper; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/LogicalConnectionImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/LogicalConnectionImpl.java index 0882c58869..8ed87047d8 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/LogicalConnectionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/LogicalConnectionImpl.java @@ -33,6 +33,7 @@ import java.util.List; import org.hibernate.ConnectionReleaseMode; import org.hibernate.HibernateException; import org.hibernate.JDBCException; +import org.hibernate.Logger; import org.hibernate.engine.jdbc.spi.ConnectionObserver; import org.hibernate.engine.jdbc.spi.JdbcResourceRegistry; import org.hibernate.engine.jdbc.spi.JdbcServices; @@ -361,21 +362,12 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { * This form is used for user-supplied connections. */ public void reconnect(Connection suppliedConnection) { - if ( isClosed ) { - throw new IllegalStateException( "cannot manually reconnect because logical connection is already closed" ); - } + if (isClosed) throw new IllegalStateException("cannot manually reconnect because logical connection is already closed"); if ( isUserSuppliedConnection ) { - if ( suppliedConnection == null ) { - throw new IllegalArgumentException( "cannot reconnect a null user-supplied connection" ); - } - else if ( suppliedConnection == physicalConnection ) { - log.warn( "reconnecting the same connection that is already connected; should this connection have been disconnected?" ); - } - else if ( physicalConnection != null ) { - throw new IllegalArgumentException( - "cannot reconnect to a new user-supplied connection because currently connected; must disconnect before reconnecting." - ); - } + if (suppliedConnection == null) throw new IllegalArgumentException("cannot reconnect a null user-supplied connection"); + else if (suppliedConnection == physicalConnection) LOG.reconnectingConnectedConnection(); + else if (physicalConnection != null) throw new IllegalArgumentException( + "cannot reconnect to a new user-supplied connection because currently connected; must disconnect before reconnecting."); physicalConnection = suppliedConnection; LOG.debug("Reconnected JDBC connection"); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/StatementPreparer.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/StatementPreparer.java index f5a08c22ad..dfadc05b10 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/StatementPreparer.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/StatementPreparer.java @@ -85,7 +85,7 @@ public class StatementPreparer { return ps; } catch ( SQLException sqle ) { - LOG.error(LOG.sqlExceptionEscapedProxy(), sqle); + LOG.sqlExceptionEscapedProxy(sqle); throw sqlExceptionHelper.convert( sqle, "could not prepare statement", sql ); @@ -109,7 +109,7 @@ public class StatementPreparer { proxiedConnection.close(); } catch (SQLException sqle) { - LOG.error(LOG.sqlExceptionEscapedProxy(), sqle); + LOG.sqlExceptionEscapedProxy(sqle); throw sqlExceptionHelper.convert( sqle, "could not close connection proxy" ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/proxy/ConnectionProxyHandler.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/proxy/ConnectionProxyHandler.java index 2b1a4b449b..86f8524d1f 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/proxy/ConnectionProxyHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/proxy/ConnectionProxyHandler.java @@ -32,6 +32,7 @@ import java.sql.DatabaseMetaData; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; +import org.hibernate.Logger; import org.hibernate.engine.jdbc.spi.ConnectionObserver; import org.hibernate.engine.jdbc.spi.JdbcResourceRegistry; import org.hibernate.engine.jdbc.spi.JdbcServices; @@ -46,7 +47,7 @@ import org.hibernate.stat.StatisticsImplementor; public class ConnectionProxyHandler extends AbstractProxyHandler implements InvocationHandler, ConnectionObserver { private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, - AbstractProxyHandler.class.getPackage().getName()); + ConnectionProxyHandler.class.getPackage().getName()); private LogicalConnectionImplementor logicalConnection; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/proxy/PreparedStatementProxyHandler.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/proxy/PreparedStatementProxyHandler.java index 3b60f80cc4..cc7da725a9 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/proxy/PreparedStatementProxyHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/proxy/PreparedStatementProxyHandler.java @@ -23,11 +23,11 @@ */ package org.hibernate.engine.jdbc.internal.proxy; -import static org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.LOG; import java.lang.reflect.Method; import java.sql.Connection; import java.sql.Statement; import java.util.Arrays; +import org.hibernate.Logger; /** * Invocation handler for {@link java.sql.PreparedStatement} proxies @@ -35,7 +35,9 @@ import java.util.Arrays; * @author Steve Ebersole */ public class PreparedStatementProxyHandler extends AbstractStatementProxyHandler { - private static final Logger log = LoggerFactory.getLogger( ConnectionProxyHandler.class ); + + private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, + PreparedStatementProxyHandler.class.getPackage().getName()); private final String sql; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SQLExceptionHelper.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SQLExceptionHelper.java index b28c46f1e8..61d4af90e7 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SQLExceptionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SQLExceptionHelper.java @@ -130,7 +130,7 @@ public class SQLExceptionHelper { } catch ( SQLException sqle ) { //workaround for WebLogic - LOG.unableToLogWarnings(sqle); + LOG.warn(LOG.unableToLogWarnings(), sqle); } } try { @@ -193,12 +193,7 @@ public class SQLExceptionHelper { if (LOG.isEnabled(ERROR)) { LOG.debug((StringHelper.isNotEmpty(message) ? message : DEFAULT_EXCEPTION_MSG) + " : " + sqlException); while ( sqlException != null ) { - StringBuffer buf = new StringBuffer( 30 ) - .append( "SQL Error: " ) - .append( sqlException.getErrorCode() ) - .append( ", SQLState: " ) - .append( sqlException.getSQLState() ); - LOG.warn(buf.toString()); + LOG.sqlException(sqlException.getErrorCode(), sqlException.getSQLState()); LOG.error(sqlException.getMessage()); sqlException = sqlException.getNextException(); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/loading/LoadContexts.java b/hibernate-core/src/main/java/org/hibernate/engine/loading/LoadContexts.java index 79a33fafd0..3767985e14 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/loading/LoadContexts.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/loading/LoadContexts.java @@ -128,7 +128,7 @@ public class LoadContexts { Iterator itr = collectionLoadContexts.values().iterator(); while ( itr.hasNext() ) { CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) itr.next(); - LOG.failSafeCleanup(collectionLoadContext); + LOG.failSafeCollectionsCleanup(collectionLoadContext); collectionLoadContext.cleanup(); } collectionLoadContexts.clear(); @@ -137,7 +137,7 @@ public class LoadContexts { Iterator itr = entityLoadContexts.values().iterator(); while ( itr.hasNext() ) { EntityLoadContext entityLoadContext = ( EntityLoadContext ) itr.next(); - LOG.failSafeCleanup(entityLoadContext); + LOG.failSafeEntitiesCleanup(entityLoadContext); entityLoadContext.cleanup(); } entityLoadContexts.clear(); diff --git a/hibernate-core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java index 1aec658858..f347542a25 100755 --- a/hibernate-core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.Set; import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; +import org.hibernate.Logger; import org.hibernate.ObjectDeletedException; import org.hibernate.PropertyValueException; import org.hibernate.StaleObjectStateException; diff --git a/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java index 8e1ca6e6ae..b2858ebc6f 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java @@ -169,7 +169,7 @@ public class MultipleHiLoPerTableGenerator rs.close(); } catch (SQLException sqle) { - LOG.error(LOG.unableToReadOrInitHiValue(), sqle); + LOG.unableToReadOrInitHiValue(sqle); throw sqle; } finally { diff --git a/hibernate-core/src/main/java/org/hibernate/id/TableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/TableGenerator.java index 790928bad5..86e71e6977 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/TableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/TableGenerator.java @@ -198,7 +198,7 @@ public class TableGenerator extends TransactionHelper rs.close(); } catch (SQLException sqle) { - LOG.error(LOG.unableToReadHiValue(), sqle); + LOG.error(LOG.unableToReadHiValue(tableName), sqle); throw sqle; } finally { diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java index 9f2ebc815b..29a8a4ad77 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java @@ -503,7 +503,7 @@ public class TableGenerator extends TransactionHelper implements PersistentIdent selectRS.close(); } catch ( SQLException sqle ) { - LOG.error(LOG.unableToReadOrInitHiValue(), sqle); + LOG.unableToReadOrInitHiValue(sqle); throw sqle; } finally { @@ -526,7 +526,7 @@ public class TableGenerator extends TransactionHelper implements PersistentIdent rows = updatePS.executeUpdate(); } catch ( SQLException sqle ) { - LOG.error(LOG.unableToUpdateQueryHiValue(tableName), sqle); + LOG.unableToUpdateQueryHiValue(tableName, sqle); throw sqle; } finally { diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java index ec88575699..e150439e81 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java @@ -178,7 +178,7 @@ public class TableStructure extends TransactionHelper implements DatabaseStructu selectRS.close(); } catch ( SQLException sqle ) { - LOG.error(LOG.unableToReadHiValue(), sqle); + LOG.error(LOG.unableToReadHiValue(tableName), sqle); throw sqle; } finally { @@ -195,7 +195,7 @@ public class TableStructure extends TransactionHelper implements DatabaseStructu rows = updatePS.executeUpdate(); } catch ( SQLException sqle ) { - LOG.error(LOG.unableToUpdateQueryHiValue(tableName), sqle); + LOG.unableToUpdateQueryHiValue(tableName, sqle); throw sqle; } finally { diff --git a/hibernate-core/src/main/java/org/hibernate/impl/IteratorImpl.java b/hibernate-core/src/main/java/org/hibernate/impl/IteratorImpl.java index c9710ff6a6..8e704d6cff 100644 --- a/hibernate-core/src/main/java/org/hibernate/impl/IteratorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/impl/IteratorImpl.java @@ -30,6 +30,7 @@ import java.sql.SQLException; import java.util.NoSuchElementException; import org.hibernate.HibernateException; import org.hibernate.JDBCException; +import org.hibernate.Logger; import org.hibernate.engine.HibernateIterator; import org.hibernate.event.EventSource; import org.hibernate.hql.HolderInstantiator; @@ -90,7 +91,7 @@ public final class IteratorImpl implements HibernateIterator { hasNext = false; } catch (SQLException e) { - log.info( "Unable to close iterator", e ); + LOG.info(LOG.unableToCloseIterator(), e); throw session.getFactory().getSQLExceptionHelper().convert( e, "Unable to close iterator" diff --git a/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java index 96bafaf8b5..e210767615 100644 --- a/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java @@ -413,7 +413,7 @@ public final class SessionFactoryImpl implements SessionFactory, SessionFactoryI HibernateException e = ( HibernateException ) errors.get( queryName ); failingQueries.append( queryName ); if (iterator.hasNext()) failingQueries.append(", "); - LOG.error(LOG.namedQueryError(queryName), e); + LOG.namedQueryError(queryName, e); } throw new HibernateException( failingQueries.toString() ); } @@ -1231,7 +1231,7 @@ public final class SessionFactoryImpl implements SessionFactory, SessionFactoryI .newInstance( new Object[] { this } ); } catch( Throwable t ) { - LOG.error(LOG.unableToConstructCurrentSessionContext(impl), t); + LOG.unableToConstructCurrentSessionContext(impl, t); return null; } } diff --git a/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryObjectFactory.java b/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryObjectFactory.java index 31b9cebc1a..88f3bb55aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryObjectFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryObjectFactory.java @@ -108,7 +108,7 @@ public class SessionFactoryObjectFactory implements ObjectFactory { ( (EventContext) ctx ).addNamingListener(name, EventContext.OBJECT_SCOPE, LISTENER); } catch (InvalidNameException ine) { - LOG.error(LOG.invalidJndiName(name), ine); + LOG.invalidJndiName(name, ine); } catch (NamingException ne) { LOG.warn(LOG.unableToBindFactoryToJndi(), ne); @@ -131,7 +131,7 @@ public class SessionFactoryObjectFactory implements ObjectFactory { LOG.factoryUnboundFromJndiName(name); } catch (InvalidNameException ine) { - LOG.error(LOG.invalidJndiName(name), ine); + LOG.invalidJndiName(name, ine); } catch (NamingException ne) { LOG.warn(LOG.unableToUnbindFactoryFromJndi(), ne); diff --git a/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java index e31c5de74e..0e820cc0ac 100644 --- a/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java @@ -556,7 +556,7 @@ public final class SessionImpl extends AbstractSessionImpl interceptor.beforeTransactionCompletion(tx); } catch (Throwable t) { - LOG.error(LOG.exceptionInBeforeTransactionCompletionInterceptor(), t); + LOG.exceptionInBeforeTransactionCompletionInterceptor(t); } } } @@ -587,7 +587,7 @@ public final class SessionImpl extends AbstractSessionImpl interceptor.afterTransactionCompletion(tx); } catch (Throwable t) { - LOG.error(LOG.exceptionInAfterTransactionCompletionInterceptor(), t); + LOG.exceptionInAfterTransactionCompletionInterceptor(t); } } if ( autoClear ) { diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java index 2d299e844c..6199c7f59c 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java @@ -189,7 +189,7 @@ public final class JndiHelper { new InitialContext(hash); } catch (NamingException e) { - LOG.error(LOG.unableToObtainInitialContext(), e); + LOG.unableToObtainInitialContext(e); throw e; } } diff --git a/hibernate-core/src/main/java/org/hibernate/jdbc/ConnectionManager.java b/hibernate-core/src/main/java/org/hibernate/jdbc/ConnectionManager.java deleted file mode 100644 index d38c3bc730..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/jdbc/ConnectionManager.java +++ /dev/null @@ -1,598 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - * - */ -package org.hibernate.jdbc; - -import static org.jboss.logging.Logger.Level.DEBUG; -import static org.jboss.logging.Logger.Level.INFO; -import static org.jboss.logging.Logger.Level.TRACE; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.sql.Connection; -import java.sql.SQLException; -import org.hibernate.ConnectionReleaseMode; -import org.hibernate.HibernateException; -import org.hibernate.Interceptor; -import org.hibernate.engine.SessionFactoryImplementor; -import org.hibernate.exception.JDBCExceptionHelper; -import org.hibernate.util.JDBCExceptionReporter; -import org.jboss.logging.BasicLogger; -import org.jboss.logging.LogMessage; -import org.jboss.logging.Message; -import org.jboss.logging.MessageLogger; - -/** - * Encapsulates JDBC Connection management logic needed by Hibernate. - *

- * The lifecycle is intended to span a logical series of interactions with the - * database. Internally, this means the the lifecycle of the Session. - * - * @author Steve Ebersole - */ -public class ConnectionManager implements Serializable { - - private static final Logger LOG = org.jboss.logging.Logger.getMessageLogger(Logger.class, - ConnectionManager.class.getPackage().getName()); - - public static interface Callback { - public void connectionOpened(); - public void connectionCleanedUp(); - public boolean isTransactionInProgress(); - } - - private transient SessionFactoryImplementor factory; - private final Callback callback; - - private final ConnectionReleaseMode releaseMode; - private transient Connection connection; - private transient Connection borrowedConnection; - - private final boolean wasConnectionSupplied; - private transient Batcher batcher; - private transient Interceptor interceptor; - private boolean isClosed; - private transient boolean isFlushing; - - /** - * Constructs a ConnectionManager. - *

- * This is the form used internally. - * - * @param factory The SessionFactory. - * @param callback An observer for internal state change. - * @param releaseMode The mode by which to release JDBC connections. - * @param connection An externally supplied connection. - */ - public ConnectionManager( - SessionFactoryImplementor factory, - Callback callback, - ConnectionReleaseMode releaseMode, - Connection connection, - Interceptor interceptor) { - this.factory = factory; - this.callback = callback; - - this.interceptor = interceptor; - this.batcher = factory.getSettings().getBatcherFactory().createBatcher( this, interceptor ); - - this.connection = connection; - wasConnectionSupplied = ( connection != null ); - - this.releaseMode = wasConnectionSupplied ? ConnectionReleaseMode.ON_CLOSE : releaseMode; - } - - /** - * Private constructor used exclusively from custom serialization - */ - private ConnectionManager( - SessionFactoryImplementor factory, - Callback callback, - ConnectionReleaseMode releaseMode, - Interceptor interceptor, - boolean wasConnectionSupplied, - boolean isClosed) { - this.factory = factory; - this.callback = callback; - - this.interceptor = interceptor; - this.batcher = factory.getSettings().getBatcherFactory().createBatcher( this, interceptor ); - - this.wasConnectionSupplied = wasConnectionSupplied; - this.isClosed = isClosed; - this.releaseMode = wasConnectionSupplied ? ConnectionReleaseMode.ON_CLOSE : releaseMode; - } - - /** - * The session factory. - * - * @return the session factory. - */ - public SessionFactoryImplementor getFactory() { - return factory; - } - - /** - * The batcher managed by this ConnectionManager. - * - * @return The batcher. - */ - public Batcher getBatcher() { - return batcher; - } - - /** - * Was the connection being used here supplied by the user? - * - * @return True if the user supplied the JDBC connection; false otherwise - */ - public boolean isSuppliedConnection() { - return wasConnectionSupplied; - } - - /** - * Retrieves the connection currently managed by this ConnectionManager. - *

- * Note, that we may need to obtain a connection to return here if a - * connection has either not yet been obtained (non-UserSuppliedConnectionProvider) - * or has previously been aggressively released (if supported in this environment). - * - * @return The current Connection. - * - * @throws HibernateException Indicates a connection is currently not - * available (we are currently manually disconnected). - */ - public Connection getConnection() throws HibernateException { - if ( isClosed ) { - throw new HibernateException( "connection manager has been closed" ); - } - if ( connection == null ) { - openConnection(); - } - return connection; - } - - public boolean hasBorrowedConnection() { - // used from testsuite - return borrowedConnection != null; - } - - public Connection borrowConnection() { - if ( isClosed ) { - throw new HibernateException( "connection manager has been closed" ); - } - if ( isSuppliedConnection() ) { - return connection; - } - else { - if ( borrowedConnection == null ) { - borrowedConnection = BorrowedConnectionProxy.generateProxy( this ); - } - return borrowedConnection; - } - } - - public void releaseBorrowedConnection() { - if ( borrowedConnection != null ) { - try { - BorrowedConnectionProxy.renderUnuseable( borrowedConnection ); - } - finally { - borrowedConnection = null; - } - } - } - - /** - * Is the connection considered "auto-commit"? - * - * @return True if we either do not have a connection, or the connection - * really is in auto-commit mode. - * - * @throws SQLException Can be thrown by the Connection.isAutoCommit() check. - */ - public boolean isAutoCommit() throws SQLException { - return connection == null - || connection.isClosed() - || connection.getAutoCommit(); - } - - /** - * Will connections be released after each statement execution? - *

- * Connections will be released after each statement if either: