I am working with Teneo/EMF/Hibernate and I've made a simple test.
This is my test code:
// LOAD A Session session = this.hbds.getSessionFactory().openSession(); Transaction transaction = session.beginTransaction(); A loadedA = (A)session.createQuery("FROM A a LEFT JOIN FETCH a.b1").list().get(0); transaction.commit(); session.flush(); session.close(); // LOAD B session = this.hbds.getSessionFactory().openSession(); transaction = session.beginTransaction(); B loadedB = (B)session.get("B", (Long)6L); transaction.commit(); session.flush(); session.close(); // ADD B TO A session = this.hbds.getSessionFactory().openSession(); transaction = session.beginTransaction(); loadedA.getB1().add(loadedB); //loadedA.getB1().add(b); session.saveOrUpdate(loadedA); transaction.commit(); session.flush(); session.close(); this.hbds.close();
Do you know what is the right configuration to work with saveOrUpdate and to avoid these errors? Or any solution to avoid this problem?
Martin Taal answered my question in Eclipse's Forum.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.