Something of an novice with HSQL and Hibernate...
em.getTransaction().begin();
for (Activity theActivity : activities) {
em.persist(theActivity);
}
em.getTransaction().commit();
em.close();
followed by...
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
System.out.println("QUERY:: "
+ em.createQuery("SELECT COUNT(*) FROM " + Activity.class.getName()).getSingleResult()
.toString());
em.getTransaction().commit();
Prints 25000 (the number of Activity objects in activities). But when I run this test again, the number of objects in the count(*) doesn't increase (and is 0 at the beginning of the program). So the objects aren't getting durably written.
This is my hsqldb connection string:
name="hibernate.connection.url" value="jdbc:hsqldb:file:data/cmon"
so it's not an in-memory database as far as I know...
Does anyone have any ideas why the objects aren't getting persisted beyond a single JVM session? Happy to supply more information but there's so much state associated with Hibernate / JPA / HSQL that it's not clear exactly what is pertinent.