-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Populate reference data from Hibernate after generating DDL?
PostPosted: Mon Jun 18, 2007 9:45 am 
Newbie

Joined: Thu Jun 07, 2007 12:45 pm
Posts: 4
Location: eastern USA
Hibernate version:
3.2.0
Mapping documents:
Annotations only

Can someone suggest a strategy for populating reference data in unit tests where hibernate is used to generate the ddl? We use an in-memory database for our JUnit tests and we have an Entity which is read-only for which we need to have rows inserted into the table that Hibernate generates for us. Is there some API for doing this directly, or perhaps some interface we could implement to provide this custom data? I looked at the AbstractAuxiliaryDatabaseObject, but it appears to be intended to customize the DDL only, not to run arbitrary insert statements after all DDL has been executed. We would like to avoid introducing a database server requirement where scripts are executed (by Ant for example) prior to running JUnit tests.

Rob

_________________
SQuirreL SQL (http://www.squirrelsql.org)


Top
 Profile  
 
 Post subject: Re: Populate reference data from Hibernate after generating
PostPosted: Mon Jun 18, 2007 1:13 pm 
Newbie

Joined: Mon Jun 18, 2007 11:25 am
Posts: 3
Location: London
Hi,

Check out DbUnit. It's rather cool, and quite easy. It can load your test data, clean out the db, etc. and it has a well thought-out usage model that I find very useful.

Cheers,

Bryan


squirreldev wrote:
Hibernate version:
3.2.0
Mapping documents:
Annotations only

Can someone suggest a strategy for populating reference data in unit tests where hibernate is used to generate the ddl? We use an in-memory database for our JUnit tests and we have an Entity which is read-only for which we need to have rows inserted into the table that Hibernate generates for us. Is there some API for doing this directly, or perhaps some interface we could implement to provide this custom data? I looked at the AbstractAuxiliaryDatabaseObject, but it appears to be intended to customize the DDL only, not to run arbitrary insert statements after all DDL has been executed. We would like to avoid introducing a database server requirement where scripts are executed (by Ant for example) prior to running JUnit tests.

Rob


Top
 Profile  
 
 Post subject: Re: Populate reference data from Hibernate after generating
PostPosted: Wed Jun 20, 2007 4:29 pm 
Newbie

Joined: Thu Jun 07, 2007 12:45 pm
Posts: 4
Location: eastern USA
Thanks for the reply. We are already using Spring's AbstractJpaTests to populate the reference data manually in code just prior to executing our test transaction.(We can count on having Hibernate setup the table structure prior to this so that works). I was thinking that approach was kludgey and that possibly there was some provision for configuring Hibernate to do that for us. But it appears that reliance on Hibernate to create the DDL and external systems for setting up data in the schema Hibernate generates is the norm.

Thanks,

Rob

_________________
SQuirreL SQL (http://www.squirrelsql.org)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2007 4:35 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
There is a handy HibernateDBUnitTest superclass in http://caveatemptor.hibernate.org

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.