Personal tools
You are here: Home Members rafiferoze Database Programming with Hibernate Hibernate with Tomcat : Required Configuration
Document Actions

Hibernate with Tomcat : Required Configuration

by Rafi Mohamed Feroze last modified 2007-08-27 22:19

This page provides information on config and pre-req files required for using Hibernate in Servlets.

Hibernate community webpage Using Hibernate with Tomcat provides a summary on this topic.

Points to note

1. If hbm2ddl.auto property is set to 'create', pre-existing data will be lost. It will appear as if persistence has failed, but what has happened is that the tables were dropped when SessionObject was created. To avoid data loss, disable the hbm2ddl.auto property after first run.

2. If using HSQL, tomcat shutdown might throw a NullPointerException. This issue is discussed in different blogs and forums Blog and forum.
Glassbox corp coder has a simple solution in destroy() method. Can include this in the HibernateListener class if HSQL is being used.
public void destroy() throws Exception {
configurationDAO = null;
try { org.hsqldb.DatabaseManager.closeDatabases(0);
org.hsqldb.DatabaseManager.getTimer().shutDown();
} catch (Throwable t) {
; // nothing we can do further: we sometimes get an NPE, presumably because the databases are already shut down
}
}


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: