You could run each test inside a transaction - just rollback after each test
[method] and you're golden.
On Tue, Jul 13, 2010 at 11:01 PM, Lev <[email protected]> wrote:
> On Tue, Jul 13, 2010 at 1:31 PM, Oscar Westra van Holthe - Kind
> <[email protected]> wrote:
> > On 13-07-2010 at 12:01, Thomas Menke wrote:
> >> On 07/13/2010 08:22 AM, Lev wrote:
> >> > would anybody happen to know how to recreate (drop, then
> >> > create) a database with stripersist?
> >> >
> >> > further, do you know how to drop/create a specific table
> >> > within a database?
> >> >
> >> > i'm using hibernate with stripersist.
> >>
> >> Do you want to change the structure of the table at runtime? If you do
> >> not want to change the structure you could use a simple truncate query.
> >>
> >> I use this property in my persistance.xml to update tables when I deploy
> >> my application:
> >>
> >> <!-- e.g. validate | update | create | create-drop -->
> >> <property name="hibernate.hbm2ddl.auto" value="update" />
> >
> > And in addition to this, if Hibernate creates your database (e.g. when
> you
> > set the property to create or create-drop), it'll try to read the file
> > "import.sql" from the root of your classpath. If the file exists,
> Hibernate
> > executes the SQL statements after creating your database. You can use
> this to
> > insert initial data.
> >
> > Personally, I use this with a HSQLDB in-memory database to test my code.
> >
> >
> > Oscar
>
> i would like to recreate the database between individual JUnit
> tests -- to ensure a clean starting state of the DB.
>
> instead of relying on the import.sql file, do you know of a way
> to do this programmatically? in other words, is there a method that
> i can write that will do this? that way, i can call it at the beginning
> of each JUnit test for which this is deemed necesarry.
>
> i have used the following in hibernate. is there a way to query the
> annotated classes registered with Stripersist?
>
> public static void recreateDatabase() {
> Configuration config = getInitializedConfiguration();
> new SchemaExport(config).create(true, true);
> }
>
> public static Configuration getInitializedConfiguration() {
> AnnotationConfiguration config = new AnnotationConfiguration();
>
> // add annotated classes
> if (annotatedClasses != null) {
> Iterator<Class> it = annotatedClasses.iterator();
> while (it.hasNext())
> config.addAnnotatedClass(it.next());
> }
> config.configure();
> return config;
> }
>
> (i believe the above code should be credited to cameron mckenzie.)
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users