Hello, this question is probably best answered by Michael Dick:

Does this code expose/represent bug 1365, or it is something new?

public void testNonUnique() throws Exception {
 EntityA a1 = setup.insertA("1");
EntityB b1 = setup.insertB("1");
EntityB b2 = setup.insertB("2");
a1.getChildren().add(b1);
a1.getChildren().add(b2);
em.getTransaction().begin();
em.persist(a1);
em.getTransaction().commit();
 em.close();
em = emf.createEntityManager();
 EntityA fresh1 = reload(a1); // OK
try {
EntityA fresh2 = reload(a1); // fail
fail("Expected exception");
} catch (Exception exc) {}

}
 private EntityA reload(EntityA original) {
Query query = em.createQuery("select distinct o from EntityA as o" +
" left join fetch o.children" +
" where o.id = :id");
query.setParameter("id", original.getId());
return (EntityA) query.getSingleResult();
}

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:da...@6degrees.com

Reply via email to