Search in sources :

Example 1 with GolferPK

use of org.eclipse.persistence.testing.models.jpa.advanced.GolferPK 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 (isWeavingEnabled()) {
        internalTestWeaving(new Employee(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), true);
        internalTestWeaving(new FormerEmployment(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new Address(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new PhoneNumber(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new EmploymentPeriod(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        // field-locking
        internalTestWeaving(new Buyer(), false, isWeavingForFetchGroupsEnabled(), false);
        // field-locking
        internalTestWeaving(new GoldBuyer(), false, isWeavingForFetchGroupsEnabled(), false);
        // field-locking
        internalTestWeaving(new PlatinumBuyer(), false, isWeavingForFetchGroupsEnabled(), false);
        // eager 1-m
        internalTestWeaving(new Department(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new Golfer(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new GolferPK(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new SmallProject(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new LargeProject(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new Man(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new Woman(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        // serialized
        internalTestWeaving(new Vegetable(), false, isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new VegetablePK(), false, isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new WorldRank(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new Equipment(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new EquipmentCode(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
        internalTestWeaving(new PartnerLink(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
    }
}
Also used : EmploymentPeriod(org.eclipse.persistence.testing.models.jpa.advanced.EmploymentPeriod) SmallProject(org.eclipse.persistence.testing.models.jpa.advanced.SmallProject) VegetablePK(org.eclipse.persistence.testing.models.jpa.advanced.VegetablePK) WorldRank(org.eclipse.persistence.testing.models.jpa.advanced.WorldRank) Address(org.eclipse.persistence.testing.models.jpa.advanced.Address) EquipmentCode(org.eclipse.persistence.testing.models.jpa.advanced.EquipmentCode) FormerEmployment(org.eclipse.persistence.testing.models.jpa.advanced.FormerEmployment) GoldBuyer(org.eclipse.persistence.testing.models.jpa.advanced.GoldBuyer) PlatinumBuyer(org.eclipse.persistence.testing.models.jpa.advanced.PlatinumBuyer) Buyer(org.eclipse.persistence.testing.models.jpa.advanced.Buyer) GoldBuyer(org.eclipse.persistence.testing.models.jpa.advanced.GoldBuyer) PlatinumBuyer(org.eclipse.persistence.testing.models.jpa.advanced.PlatinumBuyer) Department(org.eclipse.persistence.testing.models.jpa.advanced.Department) Employee(org.eclipse.persistence.testing.models.jpa.advanced.Employee) Equipment(org.eclipse.persistence.testing.models.jpa.advanced.Equipment) GolferPK(org.eclipse.persistence.testing.models.jpa.advanced.GolferPK) PhoneNumber(org.eclipse.persistence.testing.models.jpa.advanced.PhoneNumber) Golfer(org.eclipse.persistence.testing.models.jpa.advanced.Golfer) Man(org.eclipse.persistence.testing.models.jpa.advanced.Man) Woman(org.eclipse.persistence.testing.models.jpa.advanced.Woman) PartnerLink(org.eclipse.persistence.testing.models.jpa.advanced.PartnerLink) Vegetable(org.eclipse.persistence.testing.models.jpa.advanced.Vegetable) SuperLargeProject(org.eclipse.persistence.testing.models.jpa.advanced.SuperLargeProject) LargeProject(org.eclipse.persistence.testing.models.jpa.advanced.LargeProject)

Example 2 with GolferPK

use of org.eclipse.persistence.testing.models.jpa.advanced.GolferPK in project eclipselink by eclipse-ee4j.

the class EntityManagerJUnitTestSuite method testReplaceElementCollection.

// Bug 384607
public void testReplaceElementCollection() {
    EntityManager em = createEntityManager();
    beginTransaction(em);
    Golfer golfer = new Golfer();
    GolferPK pk = new GolferPK(102);
    WorldRank rank = new WorldRank();
    rank.setId(102);
    golfer.setWorldRank(rank);
    golfer.getSponsorDollars().put("Oracle", 10000);
    golfer.setGolferPK(pk);
    em.persist(golfer);
    em.persist(rank);
    em.flush();
    golfer = em.find(Golfer.class, golfer.getGolferPK());
    golfer.getSponsorDollars().put("Callaway", 20000);
    em.flush();
    clearCache();
    em.clear();
    golfer = em.find(Golfer.class, golfer.getGolferPK());
    assertTrue("Incorrect Number of sponsors", golfer.getSponsorDollars().size() == 2);
    assertTrue("Missing Sponsor: Callaway", golfer.getSponsorDollars().get("Callaway").equals(20000));
    assertTrue("Missing Sponsor: Oracle", golfer.getSponsorDollars().get("Oracle").equals(10000));
    golfer = em.find(Golfer.class, golfer.getGolferPK());
    golfer.setSponsorDollars(new HashMap<String, Integer>());
    em.flush();
    clearCache();
    em.clear();
    golfer = em.find(Golfer.class, golfer.getGolferPK());
    assertTrue("Incorrect Number of sponsors", golfer.getSponsorDollars().size() == 0);
    rollbackTransaction(em);
}
Also used : EntityManager(jakarta.persistence.EntityManager) JpaEntityManager(org.eclipse.persistence.jpa.JpaEntityManager) WorldRank(org.eclipse.persistence.testing.models.jpa.advanced.WorldRank) GolferPK(org.eclipse.persistence.testing.models.jpa.advanced.GolferPK) Golfer(org.eclipse.persistence.testing.models.jpa.advanced.Golfer)

Example 3 with GolferPK

use of org.eclipse.persistence.testing.models.jpa.advanced.GolferPK 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);
}
Also used : EntityManager(jakarta.persistence.EntityManager) JpaEntityManager(org.eclipse.persistence.jpa.JpaEntityManager) WorldRank(org.eclipse.persistence.testing.models.jpa.advanced.WorldRank) GolferPK(org.eclipse.persistence.testing.models.jpa.advanced.GolferPK) Golfer(org.eclipse.persistence.testing.models.jpa.advanced.Golfer)

Aggregations

Golfer (org.eclipse.persistence.testing.models.jpa.advanced.Golfer)3 GolferPK (org.eclipse.persistence.testing.models.jpa.advanced.GolferPK)3 WorldRank (org.eclipse.persistence.testing.models.jpa.advanced.WorldRank)3 EntityManager (jakarta.persistence.EntityManager)2 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)2 Address (org.eclipse.persistence.testing.models.jpa.advanced.Address)1 Buyer (org.eclipse.persistence.testing.models.jpa.advanced.Buyer)1 Department (org.eclipse.persistence.testing.models.jpa.advanced.Department)1 Employee (org.eclipse.persistence.testing.models.jpa.advanced.Employee)1 EmploymentPeriod (org.eclipse.persistence.testing.models.jpa.advanced.EmploymentPeriod)1 Equipment (org.eclipse.persistence.testing.models.jpa.advanced.Equipment)1 EquipmentCode (org.eclipse.persistence.testing.models.jpa.advanced.EquipmentCode)1 FormerEmployment (org.eclipse.persistence.testing.models.jpa.advanced.FormerEmployment)1 GoldBuyer (org.eclipse.persistence.testing.models.jpa.advanced.GoldBuyer)1 LargeProject (org.eclipse.persistence.testing.models.jpa.advanced.LargeProject)1 Man (org.eclipse.persistence.testing.models.jpa.advanced.Man)1 PartnerLink (org.eclipse.persistence.testing.models.jpa.advanced.PartnerLink)1 PhoneNumber (org.eclipse.persistence.testing.models.jpa.advanced.PhoneNumber)1 PlatinumBuyer (org.eclipse.persistence.testing.models.jpa.advanced.PlatinumBuyer)1 SmallProject (org.eclipse.persistence.testing.models.jpa.advanced.SmallProject)1