-->
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.  [ 2 posts ] 
Author Message
 Post subject: Testing without a Database?
PostPosted: Fri May 13, 2005 4:03 pm 
Newbie

Joined: Fri May 13, 2005 3:45 pm
Posts: 1
Location: Broomfield, CO
Hibernate version: 2.1 ?

Hello,

I'm new to setting up and configuring Hibernate myself, but have been developing with it for about a year. We are using hibernate 2.1 currently and we have a small development team that works remotely and may or may not have access to the secured network where our deployment / test database resides.

Is there a way to configure hibernate to act is if it has a database, but it doesn't really? For example new data could be saved to the hibernate cache, and loaded as if actually were in the database. Of course this data would not actually be persistent, but for development and testing purposes it would work fairly seamlessly. It would avoid each of us having to setup our own development database, using up resources on our development box.

I've done some searching on the forums and online and couldn't find anything related to this. Any insights or help would be appreciated.


Thanks,
Sheila.

_________________
~~
Sheila Hatfield, Software Consultant


Top
 Profile  
 
 Post subject: Re: Testing without a Database?
PostPosted: Fri May 13, 2005 4:16 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
ankhara33 wrote:
Hibernate version: 2.1 ?

Hello,

I'm new to setting up and configuring Hibernate myself, but have been developing with it for about a year. We are using hibernate 2.1 currently and we have a small development team that works remotely and may or may not have access to the secured network where our deployment / test database resides.

Is there a way to configure hibernate to act is if it has a database, but it doesn't really? For example new data could be saved to the hibernate cache, and loaded as if actually were in the database. Of course this data would not actually be persistent, but for development and testing purposes it would work fairly seamlessly. It would avoid each of us having to setup our own development database, using up resources on our development box.

I've done some searching on the forums and online and couldn't find anything related to this. Any insights or help would be appreciated.


Thanks,
Sheila.


look at using hsqldb and The configuration property hibernate.hbm2ddl.auto=create-drop.

This property causes hibernate to drop and recreate your hsqldb table each time you execute your code. I use it all the time for simple test cases.

You can create your SessionFactory object something like this:

Code:
         
Configuration cfg = new Configuration()
         .addResource("xxx/yyy/Mapping.hbm.xml")           
         .setProperty("hibernate.connection.driver_class","org.hsqldb.jdbcDriver")
         .setProperty("hibernate.connection.url", "jdbc:hsqldb:.")
         .setProperty("hibernate.dialect", "net.sf.hibernate.dialect.HSQLDialect")
         .setProperty("hibernate.connection.username", "sa")
         .setProperty("hibernate.connection.password", "")
         .setProperty("hibernate.connection.autocommit", "false")
         .setProperty("hibernate.show_sql", "true")
         .setProperty("hibernate.hbm2ddl.auto", "create-drop");
sessionFactory = cfg.buildSessionFactory();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.