Hello
there is this error i am having during creation of a class with a composite-id, an exception occurrs:
Code:
17:28:10,093 ERROR SessionImpl:2368 - Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:687)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:640)
...
the thing is i am pretty sure both of the components of the class are saved before the composite, here is what i'm doing, hope anyone could help me on this :
Code:
<class name="A_B" table="A_B" >
<composite-id name="comp_id" class="ilce.enciclomedia.dominio.TuplaAD_RSPK">
<key-many-to-one name="a" class="A" >
<column name="idA" />
</key-many-to-one>
<key-many-to-one name="b" class="ilce.enciclomedia.dominio.TuplaMC_RS" >
<column name="idB" />
</key-many-to-one>
</composite-id>
</class>
Code:
// instance of A already exist in db
A a = (A)session.load(A.class,idA) ;
//instance of B is new
B b = (B)session.load(B.class,idB) ;
//new A_B
A_B ab = new A_B( new comp_id(a, b) ) ;
session.saveOrUpdate(a) ;
session.saveOrUpdate(b) ;
//the A_B are 'accesible' from A, and B, so i have also tried putting this here:
//a.getA_Bs().add(ab);
//b.getA_Bs().add(ab);
session.saveOrUpdate(ab) ; //this fails as described above
that wasn't exactly the code because i'm using spring so each call to session.saveOrUpdate get a session using AOP
could someone point me where i'm doing wrong or something i'm missing
thanks in advance!
Gerardo