public class JPAMappingTest extends BaseJPAFTest {
@Test
public void testTwoPojosMappedToOneEntity() {
try {
AccountMapped2ndTime acc = new AccountMapped2ndTime();
acc.setName("account0");
EntityTransaction tx = em.getTransaction();
tx.begin();
em.persist(acc);
tx.commit();
List<AccountMapped2ndTime> results =
em.createQuery("select o from Account o where name='account0'", AccountMapped2ndTime.class).getResultList();
Assert.assertEquals(results.size(), 1, "unexpected number of results returned in query");
Assert.assertEquals(results.get(0).getId(), acc.getId(), "unexpected id in returned entity");
} finally {
em.createQuery("delete from Account o where o.name='account0'").executeUpdate();
}
}