BookCaseHibernateSessionFactory.java
package de.botzenhart.bookcase.persistence; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Configuration; public class BookCaseHibernateSessionFactory { private static final SessionFactory sessionFactory; protected static final Session session; private BookCaseHibernateSessionFactory(){} static { Configuration config = new Configuration(); config.configure(); // Get the session factory we can use for persistence sessionFactory = config.buildSessionFactory(); // Ask for a session using the JDBC information we've configured session = sessionFactory.openSession(); } public static SessionFactory getSessionFactory() { return sessionFactory; } public static Session getSession() { return session; } public static void terminateHibernateConnection() { session.close(); // Clean up after ourselves sessionFactory.close(); } }
Date: 2011-02-11 Fr
HTML generated by org-mode 7.4 in emacs 22