rajasaur wrote:
You need to modify your set also to indicate that the foreign key of the joined table maps to a key other than th eprimary key.
Code:
<set name="addresses" inverse="true" cascade="all-delete-orphan">
<key column="PID" property-ref="pid"/>
<one-to-many class="test.Address />
</set>
but the mapping is throwing a NullPointerException at EntityEntry's getLoadedvalue() method
.....
....
Caused by: org.hibernate.TransactionException: JTA commit failed:
at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:153)
at test.HibernateUtil.commitTransaction(HibernateUtil.java:213)
... 33 more
Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=sherin/16, BranchQual=, localId=16] status=STATUS_NO_TRANSACTION; - nested throwable: (java.lang.NullPointerException)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:354)
at org.jboss.tm.TxManager.commit(TxManager.java:224)
at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:126)
at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:146)
... 34 more
Caused by: java.lang.NullPointerException
at org.hibernate.engine.EntityEntry.getLoadedValue(EntityEntry.java:177)
at org.hibernate.type.CollectionType.getKeyOfOwner(CollectionType.java:304)
at org.hibernate.engine.Collections.processReachableCollection(Collections.java:156)
at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:37)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:115)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:345)
at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1473)
at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1092)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:306)
... 37 more
i found a bug report similar to this at
http://opensource2.atlassian.com/projects/hibernate/browse/HB-1526
i am using hibernate 3.1.2 and according to the bug report , the error is to be solved in verson 3.1
if anyone got this problem solved , please reply