use of org.datanucleus.samples.annotations.many_many.PetroleumSupplier in project tests by datanucleus.
the class RelationshipsTest method testManyToMany.
/**
* Test of M-N relations.
*/
public void testManyToMany() {
try {
EntityManager em = getEM();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
PetroleumSupplier s = new PetroleumSupplier(101, "Esso");
PetroleumCustomer c = new PetroleumCustomer(102, "Brians Fuels");
s.getCustomers().add(c);
c.getSuppliers().add(s);
em.persist(c);
tx.commit();
} catch (Exception e) {
e.printStackTrace();
fail("Exception thrown while creating Customers and Suppliers");
} finally {
if (tx.isActive()) {
tx.rollback();
}
em.close();
}
// TODO Retrieve the objects and check the persistence
// TODO Do some updates
} finally {
clean(PetroleumSupplier.class);
clean(PetroleumCustomer.class);
}
}
Aggregations