openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <da...@6degrees.com>
Subject Non-unique error
Date Fri, 15 Jan 2010 18:57:48 GMT
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:daryl@6degrees.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message