-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Derby lazy load problem net.sf.hibernate.AssertionFailure: o
PostPosted: Sat Jan 15, 2005 3:41 am 
Newbie

Joined: Sat Jan 15, 2005 3:06 am
Posts: 4
Hi,

When using lazy="false" with a derby database in a Set with a one-to-many relationship I have the following error. This error is not raised when using ms sql.

If I change the lazy mode to true, I don't have the problem but of course I don"t get the child record either.

The problem occurs also with a many to many relationship.

It there a compatibility problem between hibernate and Derby.

Hibernate version:2

Name and version of the database you are using:Derby

The generated SQL (show_sql=true):
Hibernate: select entity0_.code as code0_, entity0_.entityName as entityName0_, entity0_.entityValue as entityVa3_0_ from Entity entity0_ where entity0_.code=?
Hibernate: select entitymapp0_.entity_code as entity_c5___, entitymapp0_.code as code__, entitymapp0_.code as code0_, entitymapp0_.targetTable as targetTa2_0_, entitymapp0_.targetCode as targetCode0_, entitymapp0_.targetValue as targetVa4_0_ from EntityMapping entitymapp0_ where entitymapp0_.entity_code=?


net.sf.hibernate.AssertionFailure: owner not associated with session
at net.sf.hibernate.impl.SessionImpl.updateUnreachableCollection(SessionImpl.java:2915)
at net.sf.hibernate.impl.SessionImpl.flushCollections(SessionImpl.java:2788)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2261)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2239)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:463)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:373)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:242)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
at $Proxy4.read(Unknown Source)
at com.relaystar.dao.TestMasterData.testReadEntity(TestMasterData.java:218)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 21, 2005 1:34 pm 
Newbie

Joined: Sat Jan 15, 2005 3:06 am
Posts: 4
Hi,

I found the solution.

My Derby DB had CHAR(32) as PK. I changed it to VARCHAR(32) and it works.

Now the question is: where is the bug? In Hibernate or Derby. To test that I create the same table in MSSQL with VARCHAR -> No problem it works

I change it the VARCHAR to CHAR(32) (N.B. the key with a lenght less the 32 will be padded by spaces) and if failed.

I put it back to VARCHAR, notice that the PK will still have padded spaces. It failed again.

I repopulate the DB with a new set of data, means without spaces at the end of the PK and it works.

I have the feeling that the problem is in Hibernate because whatever is the DB Derby/MSSQL (I didn't test it with other DB, up to you) when PK has spaces at the end, something happen and it doesn't work anymore.

FYI here are my Hibernate Mappings:

Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping default-cascade="none">
   <class name="com.xxx.Entity" table="Entity">
      <id name="code" column="code">
         <generator class="com.xxx.IdentifierGenerator"/>
      </id>
      <set name="entityMappings" lazy="false" cascade="all-delete-orphan">
         <key column="entity_code"/>
         <one-to-many class="com.xxx.EntityMapping"/>
      </set>
   </class>
</hibernate-mapping>

<hibernate-mapping default-cascade="none">
   <class name="com.xxx.EntityMapping" table="EntityMapping">
      <id name="code" column="code">
         <generator class="com.xxx.IdentifierGenerator"/>
      </id>
      <property name="targetTable" column="targetTable" not-null="true"/>
   </class>
</hibernate-mapping>



The IdentifierGenerator is based on net.sf.hibernate.id.UUIDHexGenerator.

I'm using Hibernate 2.1.7.

Cheers
Dominique


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 6:13 am 
Newbie

Joined: Sat Jan 15, 2005 3:06 am
Posts: 4
Comment by Gavin King [21/Jan/05 11:34 PM] [ Permlink ]
No, of course it is not a bug, use the user forum.

Comment by Dominique Vernier [22/Jan/05 01:07 AM] [ Permlink ]
Could you give me a link where I can find this information because I found anything related to this exception except my request

Anyway you can agree that the error message is not so explicit:
AssertionFailureException: owner not associated with session

In my example I have only one collection.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.