Examples of EntityManagerFactory


Examples of javax.persistence.EntityManagerFactory

      TypeOverridingInDialectTest.class
    );

  @Test
  public void testOverriddenTypeInDialect() throws Exception {
    final EntityManagerFactory emf = Persistence.createEntityManagerFactory( "jpajtastandalone" );

    TransactionManager transactionManager = extractJBossTransactionManager( emf );
    transactionManager.begin();
    final EntityManager em = emf.createEntityManager();
    try {
      Poem poem = new Poem();
      poem.setName( "L'albatros" );
      poem.setPoemSocietyId( UUID.randomUUID() );
      poem.setCreation( new Date() );
      em.persist( poem );
      transactionManager.commit();
      assertThat( true ).as( "Custom type not used" ).isFalse();
    }
    catch ( RollbackException e ) {
      //make this chaing more robust
      assertThat( e.getCause().getCause().getMessage() ).isEqualTo( "Exploding type" );
    }
    finally {
      try {
        transactionManager.rollback();
      }
      catch ( Exception e ) {
        //we try
      }
      em.close();
      dropSchemaAndDatabase( emf );
      emf.close();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.