예제 #1
0
  /** @param args */
  public static void main(String[] args) {
    EntityManagerFactory emf = null;
    EntityManager em = null;

    Map<String, String> properties = new HashMap<String, String>();

    properties.put(DDL_GENERATION, DROP_AND_CREATE);
    properties.put(DDL_GENERATION_MODE, DDL_BOTH_GENERATION);
    properties.put(TARGET_DATABASE, TargetDatabase.Oracle);

    emf = PersistenceService.createEMF(properties, true, new EclipseLinkServiceFactory(), true);
    em = emf.createEntityManager();
    em.close();
    emf.close();
  }
예제 #2
0
 /**
  * @param entityName
  * @param em
  * @return number of rows deleted or -1 if delete failed
  */
 private static int deleteAll(String entityName, EntityManager em) {
   try {
     return em.createQuery("DELETE FROM " + entityName).executeUpdate();
   } catch (PersistenceException pe) {
     return -1;
   }
 }
예제 #3
0
  public static void deleteAll(EntityManager em) {
    boolean begunTX = false;

    if (!em.getTransaction().isActive()) {
      em.getTransaction().begin();
      begunTX = true;
    }

    deleteAll("Point", em);
    deleteAll("CountryLanguage", em);
    deleteAll("Language", em);
    deleteAll("Feature", em);
    deleteAll("TimeZone", em);
    deleteAll("AdminDivision", em);
    deleteAll("Country", em);
    deleteAll("Continent", em);

    em.flush();

    if (begunTX) {
      em.getTransaction().commit();
    }
    verifyDatabaseEmpty(em);
  }