Hello, I would not ask, this seems to be a common issue, but I have been struggling with this for a week and feel that I am following the examples reasonably well. I am using Pointbase 4.8 and Hibernate 2.1.
I have a parent Person.hbm.xml that specifies
<set name="contacts" inverse="true" lazy="true" cascade="all">
<key column="PERSON_ID"/>
<one-to-many class="Contact"/>
</set>
The parent's child Contact.hbm.xml specifies
<many-to-one name="person" class="Person" column="PERSON_ID" not-null="true"/>
The test code is
session = sessionFactory.openSession();
transaction = session.beginTransaction();
person1 = new Person("100", ... new HashSet()); PK is "100"
session.save(person1);
contact1 = new Contact("I", ... person1); // PK is "I"
contact2 = new Contact("B", person1); // PK is "B"
person1.getContacts().add(contact1);
person1.getContacts().add(contact2);
session.flush();
transaction.commit(); // Commit the inserts.
closeSession(session);
I have tried many variations of this code (e.g. session.save(person1) instead of session.flush()) and basically at session.flush() I get
16:49:18,282 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)...
Is there an answer to this? Thank you, David
|