Hibernate version: 3.1.1
Hi,
I am currently Unit-Testing our Hibernate Persistence Layer. My
setup() Method usually contains method calls to delete data from all tables which are affected by these tests. E.g.
Code:
Session session = HibernateManager.getTheManager().getSession();
Transaction transaction = session.beginTransaction();
session.createQuery("delete from Application").executeUpdate();
transaction.commit();
In my opinion, a method to clear all tables that are used by Hibernate would be much more convenient. A simple way to achieve something like that would be to allow wildcards in hql (like * for all Types):
Code:
session.createQuery("delete from *")
It is obvious that this does not work, at least currently. What are your ideas? How do you delete the contents of all tables?
Another way to delete everything is to drop and re-create all tables via hbm2ddl (HibernateTools), but this approach simply takes to long for unit-testing :(
Thanks in advance for all comments and help!
Kind Regards,
Matthias