Search in sources :

Example 1 with Bungalow

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

the class EntityManagerJUnitTestSuite method testClassInstanceConverter.

public void testClassInstanceConverter() {
    EntityManager em = createEntityManager();
    beginTransaction(em);
    Address add = new Address();
    add.setCity("St. Louis");
    add.setType(new Bungalow());
    em.persist(add);
    commitTransaction(em);
    int assignedSequenceNumber = add.getID();
    em.clear();
    getDatabaseSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    add = em.find(Address.class, assignedSequenceNumber);
    assertTrue("Did not correctly persist a mapping using a class-instance converter", (add.getType() instanceof Bungalow));
    beginTransaction(em);
    add = em.find(Address.class, assignedSequenceNumber);
    em.remove(add);
    commitTransaction(em);
}
Also used : EntityManager(jakarta.persistence.EntityManager) JpaEntityManager(org.eclipse.persistence.jpa.JpaEntityManager) Address(org.eclipse.persistence.testing.models.jpa.composite.advanced.member_1.Address) Bungalow(org.eclipse.persistence.testing.models.jpa.composite.advanced.member_1.Bungalow)

Example 2 with Bungalow

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

the class EntityMappingsAdvancedJUnitTestCase method testClassInstanceConverter.

public void testClassInstanceConverter() {
    EntityManager em = createEntityManager();
    beginTransaction(em);
    Address add = new Address();
    add.setCity("St. Louis");
    add.setType(new Bungalow());
    em.persist(add);
    commitTransaction(em);
    int assignedSequenceNumber = add.getId();
    em.clear();
    getDatabaseSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    add = em.find(Address.class, assignedSequenceNumber);
    assertTrue("Did not correctly persist a mapping using a class-instance converter", (add.getType() instanceof Bungalow));
    beginTransaction(em);
    em.remove(add);
    commitTransaction(em);
}
Also used : EntityManager(jakarta.persistence.EntityManager) Address(org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_1.Address) Bungalow(org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_1.Bungalow)

Aggregations

EntityManager (jakarta.persistence.EntityManager)2 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)1 Address (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_1.Address)1 Bungalow (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_1.Bungalow)1 Address (org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_1.Address)1 Bungalow (org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_1.Bungalow)1