use of org.eclipse.persistence.testing.models.jpa.fieldaccess.advanced.WorldRank in project eclipselink by eclipse-ee4j.
the class AdvancedJunitTest method testGF894.
public void testGF894() {
EntityManager em = createEntityManager();
beginTransaction(em);
try {
for (int i = 0; ; i++) {
GolferPK golferPK = new GolferPK(i);
Golfer golfer = em.find(Golfer.class, golferPK);
if (golfer == null) {
golfer = new Golfer();
golfer.setGolferPK(golferPK);
WorldRank worldRank = new WorldRank();
worldRank.setId(i);
golfer.setWorldRank(worldRank);
em.persist(worldRank);
em.persist(golfer);
commitTransaction(em);
break;
}
}
} catch (Exception e) {
fail("An exception was caught: [" + e.getMessage() + "]");
}
closeEntityManager(em);
}
use of org.eclipse.persistence.testing.models.jpa.fieldaccess.advanced.WorldRank in project eclipselink by eclipse-ee4j.
the class EntityManagerJUnitTestSuite method testWeaving.
/**
* Test that all of the classes in the advanced model were weaved as expected.
*/
public void testWeaving() {
// Only test if weaving was on, test runs without weaving must set this system property.
if (JUnitTestCase.isWeavingEnabled("fieldaccess")) {
internalTestWeaving(new Employee(), true, true);
internalTestWeaving(new FormerEmployment(), true, false);
internalTestWeaving(new Address(), true, false);
internalTestWeaving(new PhoneNumber(), true, false);
internalTestWeaving(new EmploymentPeriod(), true, false);
// field-locking
internalTestWeaving(new Buyer(), false, false);
// field-locking
internalTestWeaving(new GoldBuyer(), false, false);
// field-locking
internalTestWeaving(new PlatinumBuyer(), false, false);
internalTestWeaving(new Department(), true, false);
internalTestWeaving(new Golfer(), true, false);
internalTestWeaving(new GolferPK(), true, false);
internalTestWeaving(new SmallProject(), true, false);
internalTestWeaving(new LargeProject(), true, false);
internalTestWeaving(new Man(), true, false);
internalTestWeaving(new Woman(), true, false);
// serialized
internalTestWeaving(new Vegetable(), false, false);
internalTestWeaving(new VegetablePK(), false, false);
internalTestWeaving(new WorldRank(), true, false);
internalTestWeaving(new Equipment(), true, false);
internalTestWeaving(new EquipmentCode(), true, false);
internalTestWeaving(new PartnerLink(), true, false);
}
if (((OneToOneMapping) getDatabaseSession().getDescriptor(DatabaseField.class).getMappingForAttributeName("table")).usesIndirection()) {
fail("LAZY mapping should have been reverted as class was not weaved.");
}
}
use of org.eclipse.persistence.testing.models.jpa.fieldaccess.advanced.WorldRank in project eclipselink by eclipse-ee4j.
the class AdvancedJunitTest method testZeroId.
/**
* Test that a zero id can be used.
*/
public void testZeroId() {
EntityManager entityManager = createEntityManager();
beginTransaction(entityManager);
Golfer golfer = entityManager.find(Golfer.class, new GolferPK(0));
WorldRank rank = entityManager.find(WorldRank.class, 0);
if (golfer != null) {
entityManager.remove(golfer);
}
if (rank != null) {
entityManager.remove(rank);
}
commitTransaction(entityManager);
beginTransaction(entityManager);
rank = new WorldRank();
rank.setId(0);
entityManager.persist(rank);
commitTransaction(entityManager);
assertTrue("Zero id assigned sequence value.", rank.getId() == 0);
closeEntityManager(entityManager);
clearCache();
entityManager = createEntityManager();
beginTransaction(entityManager);
rank = new WorldRank();
rank.setId(0);
rank = entityManager.merge(rank);
commitTransaction(entityManager);
assertTrue("Zero id assigned sequence value.", rank.getId() == 0);
beginTransaction(entityManager);
rank = entityManager.find(WorldRank.class, 0);
assertTrue("Zero id assigned sequence value.", rank.getId() == 0);
entityManager.remove(rank);
commitTransaction(entityManager);
closeEntityManager(entityManager);
}
Aggregations