use of org.datanucleus.samples.annotations.one_many.unidir_2.MemberDetails in project tests by datanucleus.
the class JPQLQueryTest method testJoinMultipleFields.
/**
* Test for join across multiple fields in single join.
*/
public void testJoinMultipleFields() {
try {
EntityManager em = getEM();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
UserGroup grp = new UserGroup(101, "JPOX Users");
GroupMember member1 = new GroupMember(201, "Joe User");
MemberDetails memDets = new MemberDetails(301, "Joe", "User");
member1.setDetails(memDets);
grp.getMembers().add(member1);
em.persist(grp);
em.flush();
List result = em.createQuery("SELECT G FROM " + UserGroup.class.getName() + " G INNER JOIN G.members.details D").getResultList();
assertEquals(1, result.size());
tx.rollback();
} finally {
if (tx.isActive()) {
tx.rollback();
}
em.close();
}
} finally {
clean(UserGroup.class);
clean(GroupMember.class);
clean(MemberDetails.class);
}
}
Aggregations