Hi,
I just played around to understand circumstances where a NonUniqueObjectException is thrown and figured out that the following snipped doesn't end up with such an exception but with having two different rows in the DB.
Why does this not provoke a NonUniqueObjectException ?
Regards
Manfred
<snipped>
SessionFactory sf;
Session s;
Transaction t;
Pizza p1, p2;
sf = HibernateUtil.getSessionFactory();
/*
* Session 1
*/
s = sf.openSession();
t = s.beginTransaction();
p1 = new Pizza();
p1.setName("Test-Pizza");
s.save(p1);
t.commit();
s.clear();
s.close();
/*
* Session 2
*/
s = sf.openSession();
t = s.beginTransaction();
p2 = (Pizza)s.load(Pizza.class, p1.getId());
s.save(p1);
t.commit();
s.close();
</snipped>
|