Hey all,
I'm using java 1.5.0_06 with Hibernate 3.1.2, Annotations 3.1 beta8, and EntityManager 3.1 beta6 to connect to an AS/400 (DB2) database. I was able to get Annotations to work properly with my Objects. When I switched from using a Session to an EntityManager I get this message:
WARN org.hibernate.util.JDBCExceptionReporter - SQL Warning: -99999, SQLState: 01H20
WARN org.hibernate.util.JDBCExceptionReporter - Extra connection property is ignored.
It is displayed whenever a call to EntityTransaction.commit() is made. However, it is only displayed once (if connection pooling is not used) or twice (if connection pooling is used) and it is always the first one or two calls to commit that displays it. There is an Exception thrown but it differs between whether I use Hibernate's connection pool or c3p0's:
Hibernate
Code:
java.sql.SQLWarning: Extra connection property is ignored.
at com.ibm.as400.access.JDError.getSQLWarning(JDError.java:300)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2864)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2836)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2829)
at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1240)
at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1103)
at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:355)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:414)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:575)
at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:118)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:165)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at lig.framework.dw.hibernate.EntityManagerUtil.<clinit>(EntityManagerUtil.java:65)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at lig.framework.dw.main.DataWarehouse.main(DataWarehouse.java:80)
c3p0Code:
java.sql.SQLWarning: Extra connection property is ignored.
at com.ibm.as400.access.JDError.getSQLWarning(JDError.java:300)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2864)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2836)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2829)
at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1240)
at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1103)
at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:355)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:88)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:109)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:89)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:665)
at com.mchange.v2.resourcepool.BasicResourcePool.access$500(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1206)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:368)
I realize that these types of errors are DB specific (and a SQLState of 01Hxx is: (from IBM) Valid warning SQLSTATEs returned by a user-defined function or external procedure CALL) and the errors from both c3p0 and Hibernate seem to support this but my code (and properties) did not change when I made the switch from Session to EntityManager (other than changing each Session to an EntityManager and each Transaction to an EntityTransaction). So I was wondering if anyone else has had this problem and/or knows how to fix it. Any help would be appreciated.
Thanks,
Ben
Hibernate.cfg.xmlCode:
<!-- DB Properties -->
<property name="myeclipse.connection.profile">DataWarehouse</property>
<property name="connection.url">jdbc:as400://lig</property>
<property name="connection.username">xxxxx</property>
<property name="connection.password">xxxxx</property>
<property name="connection.driver_class">com.ibm.as400.access.AS400JDBCDriver</property>
<property name="dialect">org.hibernate.dialect.DB2400Dialect</property>
<!-- C3P0 Properties -->
<property name="c3p0.acquire_increment">2</property>
<property name="c3p0.idle_test_period">120</property>
<property name="c3p0.min_size">3</property>
<property name="c3p0.max_size">100</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.timeout">0</property>
<!-- Validation Properties -->
<event type="pre-update">
<listener class="org.hibernate.validator.event.ValidatePreUpdateEventListener"/>
</event>
<event type="pre-insert">
<listener class="org.hibernate.validator.event.ValidatePreInsertEventListener"/>
</event>
If the max_size property is set then I get two warnings, otherwise I get one.
Hibernate.propertiesCode:
#Hibernate Properties
hibernate.cache.use_second_level_cache=false
#hibernate.show_sql=true
#hibernate.use_sql_comments=true
#hibernate.format_sql=true
c3p0.propertiesCode:
c3p0.acquireRetryAttempts=30
c3p0.acquireRetryDelay=1000
c3p0.autoCommitOnClose=false
#c3p0.automaticTestTable=BlLibr.c3p0
c3p0.breakAfterAcquireFailure=false
c3p0.checkoutTimeout=0
c3p0.connectionTesterClassName=com.mchange.v2.c3p0.impl.DefaultConnectionTester
#c3p0.factoryClassLocation=null
c3p0.forceIgnoreUnresolvedTransactions=false
c3p0.maxStatementsPerConnection=0
c3p0.numHelperThreads=3
c3p0.preferredTestQuery=select * from BlLibr.c3p0
c3p0.propertyCycle=300
c3p0.testConnectionOnCheckin=true
c3p0.testConnectionOnCheckout=false
c3p0.usesTraditionalReflectiveProperties=false
Complete Stack Trace (between starting transaction and comitting it)Code:
DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 11404706932
DEBUG org.hibernate.impl.SessionImpl - setting flush mode to: COMMIT
DEBUG org.hibernate.ejb.AbstractEntityManagerImpl - Transaction not active, move to FlushMode NEVER
DEBUG org.hibernate.impl.SessionImpl - setting flush mode to: NEVER
DEBUG org.hibernate.transaction.JDBCTransaction - begin
DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
DEBUG org.hibernate.transaction.JDBCTransaction - current autocommit status: true
DEBUG org.hibernate.transaction.JDBCTransaction - disabling autocommit
DEBUG org.hibernate.jdbc.JDBCContext - after transaction begin
DEBUG org.hibernate.ejb.AbstractEntityManagerImpl - Transaction activated, move to FlushMode COMMIT
DEBUG org.hibernate.impl.SessionImpl - setting flush mode to: COMMIT
DEBUG org.hibernate.engine.query.QueryPlanCache - unable to locate HQL query plan in cache; generating (select au from AgentUser as au where au.username = 'johndoe' and au.password = 'testagt')
DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - parse() - HQL: select au from lig.framework.domain.util.user.AgentUser as au where au.username = 'johndoe' and au.password = 'testagt'
DEBUG org.hibernate.hql.ast.AST - --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| +-[FROM] 'from'
| | \-[RANGE] 'RANGE'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[DOT] '.'
| | | | | | +-[DOT] '.'
| | | | | | | +-[IDENT] 'lig'
| | | | | | | \-[IDENT] 'framework'
| | | | | | \-[IDENT] 'domain'
| | | | | \-[IDENT] 'util'
| | | | \-[IDENT] 'user'
| | | \-[IDENT] 'AgentUser'
| | \-[ALIAS] 'au'
| \-[SELECT] 'select'
| \-[IDENT] 'au'
\-[WHERE] 'where'
\-[AND] 'and'
+-[EQ] '='
| +-[DOT] '.'
| | +-[IDENT] 'au'
| | \-[IDENT] 'username'
| \-[QUOTED_STRING] ''johndoe''
\-[EQ] '='
+-[DOT] '.'
| +-[IDENT] 'au'
| \-[IDENT] 'password'
\-[QUOTED_STRING] ''testagt''
DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - select << begin [level=1, statement=select]
DEBUG org.hibernate.hql.ast.tree.FromElement - FromClause{level=1} : lig.framework.domain.util.user.AgentUser (au) -> agentuser0_
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : au -> agentuser0_.File
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : au -> agentuser0_.File
DEBUG org.hibernate.hql.ast.tree.DotNode - getDataType() : username -> org.hibernate.type.StringType@1f02b85
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : au.username -> agentuser0_.UserName
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : au -> agentuser0_.File
DEBUG org.hibernate.hql.ast.tree.DotNode - getDataType() : password -> org.hibernate.type.StringType@1f02b85
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : au.password -> agentuser0_.PassWord
DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - select : finishing up [level=1, statement=select]
DEBUG org.hibernate.hql.ast.HqlSqlWalker - processQuery() : ( SELECT ( {select clause} agentuser0_.File ) ( FromClause{level=1} LonDta.AuthWeb agentuser0_ ) ( where ( and ( = ( agentuser0_.UserName agentuser0_.File username ) 'johndoe' ) ( = ( agentuser0_.PassWord agentuser0_.File password ) 'testagt' ) ) ) )
DEBUG org.hibernate.hql.ast.util.JoinProcessor - Using FROM fragment [LonDta.AuthWeb agentuser0_]
DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - select >> end [level=1, statement=select]
DEBUG org.hibernate.hql.ast.AST - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (LonDta.AuthWeb)
+-[SELECT_CLAUSE] SelectClause: '{select clause}'
| +-[ALIAS_REF] IdentNode: 'agentuser0_.File as File5_' {alias=au, className=lig.framework.domain.util.user.AgentUser, tableAlias=agentuser0_}
| \-[SQL_TOKEN] SqlFragment: 'agentuser0_.UserName as UserName5_, agentuser0_.PassWord as PassWord5_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[au], fromElementByTableAlias=[agentuser0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'LonDta.AuthWeb agentuser0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=au,role=null,tableName=LonDta.AuthWeb,tableAlias=agentuser0_,origin=null,colums={,className=lig.framework.domain.util.user.AgentUser}}
\-[WHERE] SqlNode: 'where'
\-[AND] SqlNode: 'and'
+-[EQ] BinaryLogicOperatorNode: '='
| +-[DOT] DotNode: 'agentuser0_.UserName' {propertyName=username,dereferenceType=4,propertyPath=username,path=au.username,tableAlias=agentuser0_,className=lig.framework.domain.util.user.AgentUser,classAlias=au}
| | +-[ALIAS_REF] IdentNode: 'agentuser0_.File' {alias=au, className=lig.framework.domain.util.user.AgentUser, tableAlias=agentuser0_}
| | \-[IDENT] IdentNode: 'username' {originalText=username}
| \-[QUOTED_STRING] LiteralNode: ''johndoe''
\-[EQ] BinaryLogicOperatorNode: '='
+-[DOT] DotNode: 'agentuser0_.PassWord' {propertyName=password,dereferenceType=4,propertyPath=password,path=au.password,tableAlias=agentuser0_,className=lig.framework.domain.util.user.AgentUser,classAlias=au}
| +-[ALIAS_REF] IdentNode: 'agentuser0_.File' {alias=au, className=lig.framework.domain.util.user.AgentUser, tableAlias=agentuser0_}
| \-[IDENT] IdentNode: 'password' {originalText=password}
\-[QUOTED_STRING] LiteralNode: ''testagt''
DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - HQL: select au from lig.framework.domain.util.user.AgentUser as au where au.username = 'johndoe' and au.password = 'testagt'
DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - SQL: select agentuser0_.File as File5_, agentuser0_.UserName as UserName5_, agentuser0_.PassWord as PassWord5_ from LonDta.AuthWeb agentuser0_ where agentuser0_.UserName='johndoe' and agentuser0_.PassWord='testagt'
DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
DEBUG org.hibernate.engine.query.HQLQueryPlan - HQL param location recognition took 0 mills (select au from AgentUser as au where au.username = 'johndoe' and au.password = 'testagt')
DEBUG org.hibernate.engine.query.QueryPlanCache - located HQL query plan in cache (select au from AgentUser as au where au.username = 'johndoe' and au.password = 'testagt')
DEBUG org.hibernate.engine.query.HQLQueryPlan - find: select au from AgentUser as au where au.username = 'johndoe' and au.password = 'testagt'
DEBUG org.hibernate.engine.QueryParameters - named parameters: {}
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG org.hibernate.SQL - select agentuser0_.File as File5_, agentuser0_.UserName as UserName5_, agentuser0_.PassWord as PassWord5_ from LonDta.AuthWeb agentuser0_ where agentuser0_.UserName='johndoe' and agentuser0_.PassWord='testagt'
DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG org.hibernate.loader.Loader - processing result set
DEBUG org.hibernate.loader.Loader - result set row: 0
DEBUG org.hibernate.type.IntegerType - returning '9' as column: File5_
DEBUG org.hibernate.loader.Loader - result row: EntityKey[lig.framework.domain.util.user.AgentUser#9]
DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [lig.framework.domain.util.user.AgentUser#9]
DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Hydrating entity: [lig.framework.domain.util.user.AgentUser#9]
DEBUG org.hibernate.type.StringType - returning 'johndoe ' as column: UserName5_
DEBUG org.hibernate.type.StringType - returning 'testagt ' as column: PassWord5_
DEBUG org.hibernate.loader.Loader - done processing result set (1 rows)
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
DEBUG org.hibernate.loader.Loader - total objects hydrated: 1
DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [lig.framework.domain.util.user.AgentUser#9]
DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [lig.framework.domain.util.user.AgentUser#9]
DEBUG org.hibernate.engine.StatefulPersistenceContext - initializing non-lazy collections
U: (iteration: 840013158) total: 840013158
DEBUG org.hibernate.transaction.JDBCTransaction - commit
DEBUG org.hibernate.impl.SessionImpl - automatically flushing session
DEBUG org.hibernate.jdbc.JDBCContext - before transaction completion
DEBUG org.hibernate.impl.SessionImpl - before transaction completion
DEBUG org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
DEBUG org.hibernate.transaction.JDBCTransaction - committed JDBC Connection
DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion
DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG org.hibernate.util.JDBCExceptionReporter - SQL Warning
java.sql.SQLWarning: Extra connection property is ignored.
at com.ibm.as400.access.JDError.getSQLWarning(JDError.java:300)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2864)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2836)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:2829)
at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1240)
at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1103)
at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:355)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:414)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:575)
at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:118)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:165)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at lig.framework.dw.hibernate.EntityManagerUtil.<clinit>(EntityManagerUtil.java:65)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at lig.framework.dw.main.DataWarehouse.main(DataWarehouse.java:80)
WARN org.hibernate.util.JDBCExceptionReporter - SQL Warning: -99999, SQLState: 01H20
WARN org.hibernate.util.JDBCExceptionReporter - Extra connection property is ignored.
DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
DEBUG org.hibernate.impl.SessionImpl - after transaction completion
DEBUG org.hibernate.ejb.AbstractEntityManagerImpl - Transaction not active, move to FlushMode NEVER
DEBUG org.hibernate.impl.SessionImpl - setting flush mode to: NEVER
DEBUG org.hibernate.impl.SessionImpl - closing session
DEBUG org.hibernate.jdbc.ConnectionManager - connection already null in cleanup : no action