public void migrateDestructively(Class<? extends RawEntity<?>>... entities) { try { entityManager.setPolymorphicTypeMapper(new DefaultPolymorphicTypeMapper(entities)); entityManager.migrateDestructively(entities); } catch (SQLException e) { throw new ActiveObjectsSqlException(entityManager, e); } }
private EntityManager createEntityManagerAndUpdateDatabase() throws Exception { final Class<? extends DatabaseUpdater> databaseUpdater = isDataAnnotationPresent() ? getDataAnnotationValue() : getDataAnnotationDefaultValue(); final DatabaseConfiguration dbConfiguration = newDatabaseConfiguration(databaseUpdater); final EntityManager entityManager; if (databaseUpdater == NullDatabase.class) { entityManager = createEntityManager(); entityManager.migrateDestructively(); // empty the database DATABASES.remove(jdbc); } else if (!DATABASES.containsKey(jdbc) || !DATABASES.get(jdbc).equals(dbConfiguration)) { entityManager = createEntityManager(); entityManager.migrateDestructively(); // empty the database newInstance(databaseUpdater).update(entityManager); dbConfiguration.setEntityManager(entityManager); DATABASES.put(jdbc, dbConfiguration); } else { entityManager = DATABASES.get(jdbc).getEntityManager(); } return entityManager; }