I'm using Hibernate with the HibernateUtil class. It all works except when I try to use the HibernateUtil in the Application.onDestroy() method. I want to have it close the factory when the server is shutdown. It's an embedded database so it's saying the database is locked. This looks to me like the Application is running in one thread and the Pages in another. It's like the HibernateUtil static code is running twice. Is there a better way of using Hibernate in Wicket? Here's the code I'm using now.

###########################################################################
public class HibernateUtil {

   private static final SessionFactory sessionFactory;
   static {
       try {
           // Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
       } catch (Throwable ex) {
           // Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
           throw new ExceptionInInitializerError(ex);
       }...
#############################Application#####################################
 ...  @Override
   protected void onDestroy() {
       System.out.println("Killing database connection\n\n");
       HibernateUtil.getSessionFactory().close();
   }....
###########################################################################

--
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to