I am trying to delete Entities in a JPA/Hibernate configuration. The database is an embedded HSQL file.
This is code doing the delete:
EntityManager em = PersistenceUtility.getInstance().createEntityManager();
EntityTransaction t = em.getTransaction();
t.begin();
List<ServiceTicket> tickets = em.createQuery("from ServiceTicket").getResultList();
for (ServiceTicket ticket : tickets) {
Report report = ticket.getReport();
em.merge(report);
em.merge(ticket);
em.remove(report);
em.remove(ticket);
}
em.flush();
t.commit();
The ServiceTicket references the entitiy Report. This is why I had to remove Report first.
I do not get an error in this context. But the changes are not written to the database.
Here is the configuration of the persistence unit:
<persistence-unit name="local_hsql" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>Report</class>
<class>ServiceTicket</class>
<properties>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:file:etc/database/db1"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.connection.SetBigStringTryClob" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
What am I doing wrong?
Thanks in advance and regards from Germany
Marco