net.sf.hibernate.AssertionFailure

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Timer not executing
    via runawfe by nobody
    ,
  • I am getting an AssertionFailure - cannot cache a reference to an object with a null id when I try to do an update. Here is the sample code - NB: This has been working fine for me in hibernate versions 2.0 - 2.03 I have the following two mappings <class name="Customer" table="customers" polymorphism="explicit"> <cache usage="read-write"/> <id name="id" unsaved-value="0"> <generator class="sequence"> <param name="sequence">customers_id_seq</param> </generator> </id> <property name="postcode"/> <many-to-one name="csOwner" class="Employee" column="cs_owner" /> </class> and <class name="Employee" table="staff"> <id name="id"> <generator class="sequence"> <param name="sequence">staff_id_seq</param> </generator> </id> <property name="name"/> </class> the following main() throws the exception Session session = null; Customer customer = null; SessionFactory factory = null; try { // build factory factory = new Configuration().configure().buildSessionFactory(); System.out.println("Starting first session"); // first session gets customer instance session = factory.openSession(); customer = (Customer) session.load(Customer.class, new Long(1275)); System.out.println("Loaded customer " + customer.getId() + " has owner " + customer.getCsOwner().getId()); session.flush(); session.connection().commit(); session.close(); System.out.println("Updating address field"); // update a field customer.setPostcode("TESTING"); System.out.println("Starting second session"); // second session persists update session = factory.openSession(); session.update(customer); session.flush(); session.connection().commit(); session.close(); System.out.println("Finished"); factory.close(); } catch (Exception ex){ ex.printStackTrace(); } finally { if(session!=null)session.close(); if(factory!=null)factory.close(); System.exit(0); } If i remove the cache entry in the customer mapping everything is OK, but other wise i get net.sf.hibernate.AssertionFailure: cannot cache a reference to an object with a null id at net.sf.hibernate.type.EntityType.disassemble(EntityType.java:89) at net.sf.hibernate.impl.CacheEntry.disassemble(CacheEntry.java:36) at net.sf.hibernate.impl.CacheEntry.<init>(CacheEntry.java:27) at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:42) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178) at com.lab.model.HibBug.main(HibBug.java:46)
    via by tekno,
  • If somehow a flush happens while an object is being saved, following exception is thrown: net.sf.hibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs) at net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2605) at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2429) at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2422) at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2224) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2203) at com.alcatel.util.property.HibernatePropertyStore.getProperty(HibernatePropertyStore.java:34) at com.alcatel.util.property.ReflectionPropertyGroup.loadProperties(ReflectionPropertyGroup.java:74) at com.alcatel.util.property.PropertyManager.loadPropertyGroup(PropertyManager.java:79) at com.alcatel.util.property.PropertyManager.getPropertyGroup(PropertyManager.java:73) at com.alcatel.util.email.EmailAddress.setEmailAddress(EmailAddress.java:56) 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 net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:38) at net.sf.hibernate.type.ComponentType.setPropertyValues(ComponentType.java:230) at net.sf.hibernate.type.ComponentType.deepCopy(ComponentType.java:270) at net.sf.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:212) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:900) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720) In our case, a flush was executed during a save because the saved object contained a component (EmailAddress) that has some intelligence in it's setter method. The setter checks the email against a pattern that is stored in the DB. When retrieving the pattern (using the same (thread local) session), hibernate issues a flush, leading to the exception. This is just one example, but i guess there will be other ways of (unintentionally) flushing during a save. Currently, we worked around the problem by explicitly setting the session flushmode to NEVER, but thats not an ideal solution. Possible solutions: * Fix the ComponentType to not call the setter when saving. Does not make to much sense anyway. * SessionImpl#flushEntities should not do anything in case the status is SAVING. For completeness, the EmailAddress component: public class EmailAddress implements Serializable { private InternetAddress m_address; private String m_emailAddress; public EmailAddress() { } public EmailAddress(String emailAddress) throws MalformedEmailException { setEmailAddress(emailAddress); } public String toString() { return m_emailAddress; } /** * @hibernate.property * column="EMAIL_ADDRESS" */ public String getEmailAddress() { return m_emailAddress; } public Address getAddress() { return m_address; } public void setEmailAddress(String stringValue) throws MalformedEmailException { MailPropertyGroup mailPropertyGroup = (MailPropertyGroup) PropertyManager.getInstance().getPropertyGroup(MailPropertyGroup.GROUP_NAME); //This leads to the exception above... Pattern emailPattern = Pattern.compile(mailPropertyGroup.getEmailRegex()); Matcher matcher = emailPattern.matcher(stringValue); if (!matcher.matches()) { throw new MalformedEmailException(stringValue); } try { m_address = new InternetAddress(stringValue); //this check alone is not good enough } catch (AddressException ex) { throw new MalformedEmailException(stringValue, ex); } m_emailAddress = stringValue; }
    via by Koen Janssens,
  • Class A has a many to many Set reference to Class B Class B has a many to many Set reference to Class A Class C is a subclass of A lazy loading is enabled The classes A, B, C use custom persisters. The sets use custom collection persisters. When updating a data member of class B (migrationStatus), We see the exception shown below in the stack trace. This bug is not seen when the contents of the set are forced to load by iterating the set, eg: Set s = b.getACollection(); for (Iterator it = s.iterator(); it.hasNext();) { A a = (A)it.next(); } Hibernate mapping files for the two classes look like: (note uses the hibernate-mapping-2.0.dtd in the patch submitted with HB-419) <class name="sample.A" schema="adm" table="SAMPLE_A" persister="sample.APersister"> <meta attribute="implements">sample.hibernate.IAuditable</meta> <id name="id" type="int" unsaved-value="null"> <column name="sample_a_id" length="32"/> <generator class="sequence"> <param name="sequence">sample_a_id_seq</param> </generator> </id> <discriminator column="discriminator_column" type="string" force="false" /> <set name="childrenSites" inverse="true" lazy="true" cascade="all-delete-orphan"> <key column="parent_site_id"/> <one-to-many class="sample.A"/> </set> <many-to-one name="parent" column="parent_a_id" cascade="none" class="sample.A"/> <property name="aName" column="a_name" type="java.lang.String"/> <set name="properties" table="A_PROPERTY" inverse="true" lazy="true" cascade="all-delete-orphan"> <key column="sample_a_id" /> <one-to-many class="sample.Property" /> </set> <set name="bCollection" table="SAMPLE_AB_ASSOC" inverse="false" lazy="true" cascade="none" persister="sample.ABCollectionPersister"> <key column="SAMPLE_A_ID"/> <many-to-many column="SAMPLE_B_ID" class="sample.B"/> </set> <subclass name="sample.C" persister="sample.CPersister"> <property name="cURI" column="c_uri" type="string" unique="true"/> </subclass> </class> <class name="sample.B" schema="adm" table="SAMPLE_B" persister="sample.BPersister"> <meta attribute="implements">sample.hibernate.IAuditable</meta> <id name="primaryKey" type="java.lang.Integer" unsaved-value="null"> <column name="sample_b_id" length="16"/> <generator class="sequence"> <param name="sequence">sample_b_id_seq</param> </generator> </id> <property name="bId" type="java.lang.String" length="16" not-null="true" column="building_id"/> <property name="bName" type="java.lang.String" length="35" not-null="false" column="b_name"/> <property name="migrationStatus" type="java.lang.Character" length="1" not-null="false" column="migration_status" /> <set name="aCollection" table="SAMPLE_AB_ASSOC" inverse="true" lazy="true" cascade="none" persister="sample.ABCollectionPersister"> <key column="sample_B_ID"/> <many-to-many column="sample_A_ID" class="sample.A"/> </set> </class> Stack Trace: net.sf.hibernate.AssertionFailure: Hibernate has a bug processing collections at net.sf.hibernate.impl.SessionImpl$CollectionEntry.postFlush(SessionImpl.java:365) at net.sf.hibernate.impl.SessionImpl.postFlush(SessionImpl.java:2800) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2205) at sample.ABAssocTest.doUpdateAWithAssocB(ABAssocTest.java:95) at sample.ABAssocTest.testUpdateOnRealDataCase(ABAssocTest.java:55) 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: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:392) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
    via by Kelley Stover,
  • I am getting an AssertionFailure - cannot cache a reference to an object with a null id when I try to do an update. Here is the sample code - NB: This has been working fine for me in hibernate versions 2.0 - 2.03 I have the following two mappings <class name="Customer" table="customers" polymorphism="explicit"> <cache usage="read-write"/> <id name="id" unsaved-value="0"> <generator class="sequence"> <param name="sequence">customers_id_seq</param> </generator> </id> <property name="postcode"/> <many-to-one name="csOwner" class="Employee" column="cs_owner" /> </class> and <class name="Employee" table="staff"> <id name="id"> <generator class="sequence"> <param name="sequence">staff_id_seq</param> </generator> </id> <property name="name"/> </class> the following main() throws the exception Session session = null; Customer customer = null; SessionFactory factory = null; try { // build factory factory = new Configuration().configure().buildSessionFactory(); System.out.println("Starting first session"); // first session gets customer instance session = factory.openSession(); customer = (Customer) session.load(Customer.class, new Long(1275)); System.out.println("Loaded customer " + customer.getId() + " has owner " + customer.getCsOwner().getId()); session.flush(); session.connection().commit(); session.close(); System.out.println("Updating address field"); // update a field customer.setPostcode("TESTING"); System.out.println("Starting second session"); // second session persists update session = factory.openSession(); session.update(customer); session.flush(); session.connection().commit(); session.close(); System.out.println("Finished"); factory.close(); } catch (Exception ex){ ex.printStackTrace(); } finally { if(session!=null)session.close(); if(factory!=null)factory.close(); System.exit(0); } If i remove the cache entry in the customer mapping everything is OK, but other wise i get net.sf.hibernate.AssertionFailure: cannot cache a reference to an object with a null id at net.sf.hibernate.type.EntityType.disassemble(EntityType.java:89) at net.sf.hibernate.impl.CacheEntry.disassemble(CacheEntry.java:36) at net.sf.hibernate.impl.CacheEntry.<init>(CacheEntry.java:27) at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:42) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178) at com.lab.model.HibBug.main(HibBug.java:46)
    via by tekno,
  • Class A has a many to many Set reference to Class B Class B has a many to many Set reference to Class A Class C is a subclass of A lazy loading is enabled The classes A, B, C use custom persisters. The sets use custom collection persisters. When updating a data member of class B (migrationStatus), We see the exception shown below in the stack trace. This bug is not seen when the contents of the set are forced to load by iterating the set, eg: Set s = b.getACollection(); for (Iterator it = s.iterator(); it.hasNext();) { A a = (A)it.next(); } Hibernate mapping files for the two classes look like: (note uses the hibernate-mapping-2.0.dtd in the patch submitted with HB-419) <class name="sample.A" schema="adm" table="SAMPLE_A" persister="sample.APersister"> <meta attribute="implements">sample.hibernate.IAuditable</meta> <id name="id" type="int" unsaved-value="null"> <column name="sample_a_id" length="32"/> <generator class="sequence"> <param name="sequence">sample_a_id_seq</param> </generator> </id> <discriminator column="discriminator_column" type="string" force="false" /> <set name="childrenSites" inverse="true" lazy="true" cascade="all-delete-orphan"> <key column="parent_site_id"/> <one-to-many class="sample.A"/> </set> <many-to-one name="parent" column="parent_a_id" cascade="none" class="sample.A"/> <property name="aName" column="a_name" type="java.lang.String"/> <set name="properties" table="A_PROPERTY" inverse="true" lazy="true" cascade="all-delete-orphan"> <key column="sample_a_id" /> <one-to-many class="sample.Property" /> </set> <set name="bCollection" table="SAMPLE_AB_ASSOC" inverse="false" lazy="true" cascade="none" persister="sample.ABCollectionPersister"> <key column="SAMPLE_A_ID"/> <many-to-many column="SAMPLE_B_ID" class="sample.B"/> </set> <subclass name="sample.C" persister="sample.CPersister"> <property name="cURI" column="c_uri" type="string" unique="true"/> </subclass> </class> <class name="sample.B" schema="adm" table="SAMPLE_B" persister="sample.BPersister"> <meta attribute="implements">sample.hibernate.IAuditable</meta> <id name="primaryKey" type="java.lang.Integer" unsaved-value="null"> <column name="sample_b_id" length="16"/> <generator class="sequence"> <param name="sequence">sample_b_id_seq</param> </generator> </id> <property name="bId" type="java.lang.String" length="16" not-null="true" column="building_id"/> <property name="bName" type="java.lang.String" length="35" not-null="false" column="b_name"/> <property name="migrationStatus" type="java.lang.Character" length="1" not-null="false" column="migration_status" /> <set name="aCollection" table="SAMPLE_AB_ASSOC" inverse="true" lazy="true" cascade="none" persister="sample.ABCollectionPersister"> <key column="sample_B_ID"/> <many-to-many column="sample_A_ID" class="sample.A"/> </set> </class> Stack Trace: net.sf.hibernate.AssertionFailure: Hibernate has a bug processing collections at net.sf.hibernate.impl.SessionImpl$CollectionEntry.postFlush(SessionImpl.java:365) at net.sf.hibernate.impl.SessionImpl.postFlush(SessionImpl.java:2800) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2205) at sample.ABAssocTest.doUpdateAWithAssocB(ABAssocTest.java:95) at sample.ABAssocTest.testUpdateOnRealDataCase(ABAssocTest.java:55) 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: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:392) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
    via by Kelley Stover,
  • If somehow a flush happens while an object is being saved, following exception is thrown: net.sf.hibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs) at net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2605) at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2429) at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2422) at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2224) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2203) at com.alcatel.util.property.HibernatePropertyStore.getProperty(HibernatePropertyStore.java:34) at com.alcatel.util.property.ReflectionPropertyGroup.loadProperties(ReflectionPropertyGroup.java:74) at com.alcatel.util.property.PropertyManager.loadPropertyGroup(PropertyManager.java:79) at com.alcatel.util.property.PropertyManager.getPropertyGroup(PropertyManager.java:73) at com.alcatel.util.email.EmailAddress.setEmailAddress(EmailAddress.java:56) 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 net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:38) at net.sf.hibernate.type.ComponentType.setPropertyValues(ComponentType.java:230) at net.sf.hibernate.type.ComponentType.deepCopy(ComponentType.java:270) at net.sf.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:212) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:900) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720) In our case, a flush was executed during a save because the saved object contained a component (EmailAddress) that has some intelligence in it's setter method. The setter checks the email against a pattern that is stored in the DB. When retrieving the pattern (using the same (thread local) session), hibernate issues a flush, leading to the exception. This is just one example, but i guess there will be other ways of (unintentionally) flushing during a save. Currently, we worked around the problem by explicitly setting the session flushmode to NEVER, but thats not an ideal solution. Possible solutions: * Fix the ComponentType to not call the setter when saving. Does not make to much sense anyway. * SessionImpl#flushEntities should not do anything in case the status is SAVING. For completeness, the EmailAddress component: public class EmailAddress implements Serializable { private InternetAddress m_address; private String m_emailAddress; public EmailAddress() { } public EmailAddress(String emailAddress) throws MalformedEmailException { setEmailAddress(emailAddress); } public String toString() { return m_emailAddress; } /** * @hibernate.property * column="EMAIL_ADDRESS" */ public String getEmailAddress() { return m_emailAddress; } public Address getAddress() { return m_address; } public void setEmailAddress(String stringValue) throws MalformedEmailException { MailPropertyGroup mailPropertyGroup = (MailPropertyGroup) PropertyManager.getInstance().getPropertyGroup(MailPropertyGroup.GROUP_NAME); //This leads to the exception above... Pattern emailPattern = Pattern.compile(mailPropertyGroup.getEmailRegex()); Matcher matcher = emailPattern.matcher(stringValue); if (!matcher.matches()) { throw new MalformedEmailException(stringValue); } try { m_address = new InternetAddress(stringValue); //this check alone is not good enough } catch (AddressException ex) { throw new MalformedEmailException(stringValue, ex); } m_emailAddress = stringValue; }
    via by Koen Janssens,
  • 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) 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 changed 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: <!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
    via by Dominique Vernier,
    • net.sf.hibernate.AssertionFailure: owner not associated with session at net.sf.hibernate.impl.SessionImpl.updateUnreachableCollection(SessionImpl.java:2947) at net.sf.hibernate.impl.SessionImpl.flushCollections(SessionImpl.java:2816) at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2282) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2260) at ru.runa.commons.hibernate.HibernateSessionFactory.closeSession(HibernateSessionFactory.java:115) at ru.runa.af.dao.impl.HibernateSessionFactory.closeSession(HibernateSessionFactory.java:51) at ru.runa.af.dao.impl.DAOHibernateImpl.close(DAOHibernateImpl.java:51) at ru.runa.af.dao.impl.DAOHelper.close(DAOHelper.java:39) at ru.runa.af.dao.impl.DAOHelper.closeComitted(DAOHelper.java:51) at ru.runa.af.authenticaion.SubjectPrincipalsHelper.getActorById(SubjectPrincipalsHelper.java:68) at ru.runa.af.authenticaion.SubjectPrincipalsHelper.getActor(SubjectPrincipalsHelper.java:55) at ru.runa.wf.logic.JbpmCommonLogic.getActorCodeAsString(JbpmCommonLogic.java:155) at ru.runa.wf.logic.JbpmCommonLogic.openExecutionService(JbpmCommonLogic.java:137) at ru.runa.wf.logic.JbpmDefinitionLogic.getFile(JbpmDefinitionLogic.java:416)
    No Bugmate found.