Ok, perhaps I'm not using drop properly for the server database. In the following test I'm expecting the second row count to be 0 if the database is dropped but that doesnt seem to be the case. Could you advise?
The removal of UPDATE/DELETE limitations would definitely get my vote on the feature request list.
public class TestDropTable3 {
@Test
public void testDrop() {
EntityManagerFactory emf =
Persistence.createEntityManagerFactory(
"objectdb://localhost/testDrop.tmp;user=admin;password=admin");
EntityManager em = emf.createEntityManager();
em.getMetamodel().entity(CacheData.class);
em.close();
String payload = "somedata";
em = emf.createEntityManager();
CacheData data = new CacheData();
data.setHash(payload.hashCode());
data.setData(payload);
em.getTransaction().begin();
em.persist(data);
em.getTransaction().commit();
em.clear();
TypedQuery<Long> q = em.createQuery("SELECT COUNT(d) from CacheData d", Long.class);
long rows = q.getSingleResult();
System.out.println(String.format("Found %s rows", rows));
em.close();
emf.close();
emf = Persistence.createEntityManagerFactory(
"objectdb://localhost/testDrop.tmp;drop;user=admin;password=admin");
em = emf.createEntityManager();
em.getMetamodel().entity(CacheData.class);
em.close();
em = emf.createEntityManager();
q = em.createQuery("SELECT COUNT(d) from CacheData d", Long.class);
rows = q.getSingleResult();
System.out.println(String.format("Found %s rows", rows));
em.close();
emf.close();
}
@Entity
public static class CacheData {
@GeneratedValue @Id long id;
@Index int hash;
String data;
public long getId() { return id; }
public int getHash() { return hash; }
public void setHash(int value) { hash = value; }
public String getData() { return data; }
public void setData(String value) { data = value; }
}
}