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();