Search in sources :

Example 1 with DriversLicense

use of org.springframework.orm.jpa.domain.DriversLicense in project spring-framework by spring-projects.

the class AbstractContainerEntityManagerFactoryIntegrationTests method testLazyLoading.

@Test
public void testLazyLoading() {
    try {
        Person tony = new Person();
        tony.setFirstName("Tony");
        tony.setLastName("Blair");
        tony.setDriversLicense(new DriversLicense("8439DK"));
        sharedEntityManager.persist(tony);
        setComplete();
        endTransaction();
        startNewTransaction();
        sharedEntityManager.clear();
        Person newTony = entityManagerFactory.createEntityManager().getReference(Person.class, tony.getId());
        assertNotSame(newTony, tony);
        endTransaction();
        assertNotNull(newTony.getDriversLicense());
        newTony.getDriversLicense().getSerialNumber();
    } finally {
        deleteFromTables("person", "drivers_license");
    }
}
Also used : DriversLicense(org.springframework.orm.jpa.domain.DriversLicense) Person(org.springframework.orm.jpa.domain.Person) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DriversLicense (org.springframework.orm.jpa.domain.DriversLicense)1 Person (org.springframework.orm.jpa.domain.Person)1