Hi,
I am trying to migrate from hibernate 3.1.3 to 3.2.1 ga.
I changed all the return types of COUNT to Long (as specified in the migration document) but the other modifications does not seems to concern me.
However, when I run my unit tests, I get this error which I cannot understand (was working fine with 2.1.7c and after 3.1.3, this is an old piece of code that has not changed for years).
I have put as much information as I can, hope it helps you pin point the problem.
Thanks,
Daniel
Hibernate version: 3.2.1.ga
Mapping documents:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class table="cenacodem" name="com.rf1.data.sage.NarrativeCode" schema="scheme">
<composite-id class="com.rf1.data.sage.NarrativeCodeId" name="id">
<key-property type="com.rf1.data.types.TrimmedString" column="kind" length="3" name="kind"/>
<key-property type="com.rf1.data.types.TrimmedString" column="code" length="10" name="code"/>
</composite-id>
<discriminator type="string" force="true" column="kind" length="3" not-null="true" insert="false"/>
<property name="description" not-null="true" length="60" type="com.rf1.data.types.TrimmedString" column="description"/>
<subclass name="com.rf1.data.sage.Event" discriminator-value="019"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
NarrativeCodeId id = Event.newId();
id.setCode(parameters.getCode());
Event event = (Event) session.load(Event.class, id, LockMode.NONE);
event.setDescription(description);
//I get the same error if I try to access getDescription() although eclipse seems to be able to retrieve it correctly in the debugger view!?!?!?!
Full stack trace of any exception that occurs:
java.lang.IllegalAccessException-->Class org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer can not access a member of class com.rf1.data.sage.NarrativeCode with modifiers "public"
] [net.sf.cglib.proxy.UndeclaredThrowableException: java.lang.IllegalAccessException-->Class org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer can not access a member of class com.rf1.data.sage.NarrativeCode
with modifiers "public"
at com.rf1.data.sage.Event$$EnhancerByCGLIB$$37bbbb49.setDescription(<generated>)
at com.rf1.ws.sage.event.SageEventSoapBindingImpl.addOrUpdateEvent(SageEventSoapBindingImpl.java:169)
at com.rf1.ws.sage.event.OperationAddOrUpdateEventTest.testAddOrUpdateEvent01(OperationAddOrUpdateEventTest.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
Caused by: java.lang.IllegalAccessException: Class org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer can not access a member of class com.rf1.data.sage.NarrativeCode with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
at java.lang.reflect.Method.invoke(Method.java:317)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:147)
... 18 more
Name and version of the database you are using: PostgreSQL 8.0.4
The generated SQL (show_sql=true):
Hibernate: select event0_.kind as kind4_0_, event0_.code as code4_0_, event0_.description as descript3_4_0_ from scheme.cenacodem event0_ where event0_.kind=? and event0_.code=? and event0_.kind='019'
Debug level Hibernate log excerpt:
2750 [main] DEBUG - instantiated session factory
2750 [main] DEBUG - Checking 0 named HQL queries
2750 [main] DEBUG - Checking 0 named SQL queries
2953 [main] DEBUG - opened session at timestamp: 11683446140
2969 [main] DEBUG - begin
2969 [main] DEBUG - opening JDBC connection
2969 [main] DEBUG - total checked-out connections: 0
2969 [main] DEBUG - using pooled JDBC connection, pool size: 0
2969 [main] DEBUG - current autocommit status: false
2969 [main] DEBUG - after transaction begin
3016 [main] DEBUG - unable to locate HQL query plan in cache; generating (Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?))
3094 [main] DEBUG - parse() - HQL: Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?)
3125 [main] DEBUG - --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| +-[FROM] 'from'
| | \-[RANGE] 'RANGE'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[DOT] '.'
| | | | | | +-[IDENT] 'com'
| | | | | | \-[IDENT] 'rf1'
| | | | | \-[IDENT] 'data'
| | | | \-[IDENT] 'sage'
| | | \-[IDENT] 'Event'
| | \-[ALIAS] 'b'
| \-[SELECT] 'Select'
| \-[COUNT] 'count'
| \-[DOT] '.'
| +-[IDENT] 'b'
| \-[IDENT] 'description'
\-[WHERE] 'where'
\-[EQ] '='
+-[DOT] '.'
| +-[DOT] '.'
| | +-[IDENT] 'b'
| | \-[IDENT] 'id'
| \-[IDENT] 'code'
\-[PARAM] '?'
3125 [main] DEBUG - throwQueryException() : no errors
3187 [main] DEBUG - select << begin [level=1, statement=select]
3203 [main] DEBUG - FromClause{level=1} : com.rf1.data.sage.Event (b) -> event0_
3203 [main] DEBUG - Resolved : b -> (event0_.kind, event0_.code)
3203 [main] DEBUG - handling property dereference [com.rf1.data.sage.Event (b) -> description (class)]
3203 [main] DEBUG - getDataType() : description -> org.hibernate.type.CustomType@2a2cc
3203 [main] DEBUG - Resolved : b.description -> event0_.description
3219 [main] DEBUG - Resolved : b -> (event0_.kind, event0_.code)
3219 [main] DEBUG - handling property dereference [com.rf1.data.sage.Event (b) -> id (class)]
3219 [main] DEBUG - getDataType() : id -> org.hibernate.type.ComponentType@6c2896
3219 [main] DEBUG - Unresolved property path is now 'id.code'
3219 [main] DEBUG - Resolved : b.id -> event0_.code
3219 [main] DEBUG - getDataType() : id.code -> org.hibernate.type.CustomType@dccfab
3219 [main] DEBUG - Resolved : b.id.code -> event0_.code
3219 [main] DEBUG - select : finishing up [level=1, statement=select]
3219 [main] DEBUG - processQuery() : ( SELECT ( {select clause} ( count ( event0_.description (event0_.kind, event0_.code) description ) ) ) ( FromClause{level=1} scheme.cenacodem event0_ ) ( where ( = ( event0_.code ( event0_.code (event0_.kind, event0_.code) id ) code ) ? ) ) )
3234 [main] DEBUG - Using FROM fragment [scheme.cenacodem event0_]
3234 [main] DEBUG - Using WHERE fragment [event0_.kind='019']
3234 [main] DEBUG - select >> end [level=1, statement=select]
3234 [main] DEBUG - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (scheme.cenacodem)
+-[SELECT_CLAUSE] SelectClause: '{select clause}'
| +-[COUNT] CountNode: 'count'
| | \-[DOT] DotNode: 'event0_.description' {propertyName=description,dereferenceType=4,propertyPath=description,path=b.description,tableAlias=event0_,className=com.rf1.data.sage.Event,classAlias=b}
| | +-[ALIAS_REF] IdentNode: '(event0_.kind, event0_.code)' {alias=b, className=com.rf1.data.sage.Event, tableAlias=event0_}
| | \-[IDENT] IdentNode: 'description' {originalText=description}
| \-[SELECT_COLUMNS] SqlNode: ' as col_0_0_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[b], fromElementByTableAlias=[event0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'scheme.cenacodem event0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=b,role=null,tableName=scheme.cenacodem,tableAlias=event0_,origin=null,colums={,className=com.rf1.data.sage.Event}}
\-[WHERE] SqlNode: 'where'
+-[FILTERS] SqlNode: '{filter conditions}'
| \-[SQL_TOKEN] SqlFragment: 'event0_.kind='019''
\-[EQ] BinaryLogicOperatorNode: '='
+-[DOT] DotNode: 'event0_.code' {propertyName=code,dereferenceType=4,propertyPath=id.code,path=b.id.code,tableAlias=event0_,className=com.rf1.data.sage.Event,classAlias=b}
| +-[DOT] DotNode: 'event0_.code' {propertyName=code,dereferenceType=2,propertyPath=id.code,path=b.id,tableAlias=event0_,className=com.rf1.data.sage.Event,classAlias=b}
| | +-[ALIAS_REF] IdentNode: '(event0_.kind, event0_.code)' {alias=b, className=com.rf1.data.sage.Event, tableAlias=event0_}
| | \-[IDENT] IdentNode: 'id' {originalText=id}
| \-[IDENT] IdentNode: 'code' {originalText=code}
\-[PARAM] ParameterNode: '?' {ordinal=0, expectedType=org.hibernate.type.CustomType@dccfab}
3234 [main] DEBUG - throwQueryException() : no errors
3250 [main] DEBUG - HQL: Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?)
3250 [main] DEBUG - SQL: select count(event0_.description) as col_0_0_ from scheme.cenacodem event0_ where event0_.kind='019' and event0_.code=?
3250 [main] DEBUG - throwQueryException() : no errors
3266 [main] DEBUG - HQL param location recognition took 0 mills (Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?))
3281 [main] DEBUG - located HQL query plan in cache (Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?))
3281 [main] DEBUG - find: Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?)
3281 [main] DEBUG - parameters: [27/11/2003]
3281 [main] DEBUG - named parameters: {}
3281 [main] DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
3281 [main] DEBUG - select count(event0_.description) as col_0_0_ from scheme.cenacodem event0_ where event0_.kind='019' and event0_.code=?
3281 [main] DEBUG - preparing statement
3297 [main] DEBUG - binding '27/11/2003' to parameter: 1
3328 [main] DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
3328 [main] DEBUG - processing result set
3328 [main] DEBUG - result set row: 0
3328 [main] DEBUG - result row:
3328 [main] DEBUG - returning '1' as column: col_0_0_
3328 [main] DEBUG - done processing result set (1 rows)
3328 [main] DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
3328 [main] DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
3328 [main] DEBUG - closing statement
3328 [main] DEBUG - initializing non-lazy collections
3344 [main] DEBUG - loading entity: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3344 [main] DEBUG - creating new proxy for entity
3359 [main] DEBUG - initializing proxy: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - attempting to resolve: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - object not resolved in any cache: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - Fetching entity: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - loading entity: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
3359 [main] DEBUG - select event0_.kind as kind4_0_, event0_.code as code4_0_, event0_.description as descript3_4_0_ from scheme.cenacodem event0_ where event0_.kind=? and event0_.code=? and event0_.kind='019'
3359 [main] DEBUG - preparing statement
3359 [main] DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
3359 [main] DEBUG - processing result set
3359 [main] DEBUG - result set row: 0
3359 [main] DEBUG - result row: EntityKey[com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - Initializing object from ResultSet: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - Hydrating entity: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3375 [main] DEBUG - done processing result set (1 rows)
3375 [main] DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
3375 [main] DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
3375 [main] DEBUG - closing statement
3375 [main] DEBUG - total objects hydrated: 1
3375 [main] DEBUG - resolving associations for [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3375 [main] DEBUG - done materializing entity [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3375 [main] DEBUG - initializing non-lazy collections
3375 [main] DEBUG - done entity load
3453 [main] DEBUG - rollback
3453 [main] DEBUG - rolled back JDBC Connection
3453 [main] DEBUG - after transaction completion
3453 [main] DEBUG - aggressively releasing JDBC connection
3453 [main] DEBUG - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
3453 [main] DEBUG - returning connection to pool, pool size: 1
3453 [main] DEBUG - after transaction completion
3453 [main] DEBUG - disconnecting session
3453 [main] DEBUG - connection already null in cleanup : no action
3453 [main] DEBUG - closing session
3453 [main] DEBUG - connection already null in cleanup : no action
|