예제 #1
0
 @Test
 public void testOrm2() {
   PersistenceUnitInfoImpl pui =
       new PersistenceUnitInfoImpl("orm2-test", "2.0")
           .addMappingFileName("org/hibernate/jpa/test/jee/valid-orm-2.xml");
   HibernatePersistenceProvider hp = new HibernatePersistenceProvider();
   EntityManagerFactory emf = hp.createContainerEntityManagerFactory(pui, Collections.EMPTY_MAP);
   try {
     emf.getMetamodel().entity(Lighter.class); // exception if not entity
   } finally {
     emf.close();
   }
 }
예제 #2
0
 @Test
 public void testInvalidOrm1() {
   PersistenceUnitInfoImpl pui =
       new PersistenceUnitInfoImpl("invalid-orm1-test", "1.0")
           .addMappingFileName("org/hibernate/jpa/test/jee/invalid-orm-1.xml");
   HibernatePersistenceProvider hp = new HibernatePersistenceProvider();
   EntityManagerFactory emf = null;
   try {
     emf = hp.createContainerEntityManagerFactory(pui, Collections.EMPTY_MAP);
     Assert.fail("expecting 'invalid content' error");
   } catch (InvalidMappingException | AnnotationException expected) {
     // expected condition
   } catch (PersistenceException expected) {
     // expected condition
   } finally {
     if (emf != null) {
       emf.close();
     }
   }
 }
 @Override
 public void generateSchema(PersistenceUnitInfo info, Map map) {
   logDeprecation();
   super.generateSchema(info, map);
 }