public PackagingRule packaging = new PackagingRule( "persistencexml/jpajtastandalone.xml", Hero.class, SuperHero.class );
@Test
public void testJPAPolymorphicFind() throws Exception {
final EntityManagerFactory emf = Persistence.createEntityManagerFactory( "jpajtastandalone",
TestHelper.getEnvironmentProperties() );
TransactionManager transactionManager = extractJBossTransactionManager( emf );
transactionManager.begin();
final EntityManager em = emf.createEntityManager();
Hero h = new Hero();
h.setName( "Spartacus" );
em.persist( h );
SuperHero sh = new SuperHero();
sh.setName( "Batman" );
sh.setSpecialPower( "Technology and samurai techniques" );
em.persist( sh );
transactionManager.commit();
em.clear();
transactionManager.begin();
Hero lh = em.find( Hero.class, h.getName() );
assertThat( lh ).isNotNull();
assertThat( lh ).isInstanceOf( Hero.class );
Hero lsh = em.find( Hero.class, sh.getName() );
assertThat( lsh ).isNotNull();
assertThat( lsh ).isInstanceOf( SuperHero.class );
em.remove( lh );
em.remove( lsh );
transactionManager.commit();
em.close();
dropSchemaAndDatabase( emf );
emf.close();
}