[jboss-user] [EJB 3.0] - Clean complete database
hamtho2
do-not-reply at jboss.com
Tue Sep 25 09:44:57 EDT 2007
Hi,
is there a good way to clean the whole database through hibernate?
The background is as follows: I want to clean the database every time before starting a new testcase, to make sure the database is empty and in a defined state. Currently I´m doing this through dropping the scheme and restarting the session, but this takes very long. Therefor a CREATE-DROP in the persistence manager would not be very suitable as well, as I want to prevent hibernate from doing the mapping everytime.
I tried doing it through the Hibernate Criteria-API, fetching all java.lang.Objects and performing a session.delete(object) on every object, but this leads to a not-null or transient object exception, although I did it in one transaction with setting the flushMode to "commit".
The other way I tried was doing this through HQL, but this leads to the problem, that I´m working with @CollectionOfElements which I cannot reference through hql (or at least I haven´t found a way to do it), but the HQL does explicitly no cascades.
Any help would be greatly appriciated.
Thomas
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4088415#4088415
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4088415
More information about the jboss-user
mailing list