com.laszlomarket
Class ConnectionFactory
java.lang.Object
com.laszlomarket.ConnectionFactory
- public class ConnectionFactory
- extends java.lang.Object
Singleton class that creates and returns an open Hibernate Session
to the user.
- Author:
- Norman Klein
Constructor Summary |
private |
ConnectionFactory()
The Hibernate Configuration contains all the classes to be
persisted by Hibernate. |
Method Summary |
static ConnectionFactory |
getInstance()
getInstance() returns the instance of the ConnectionFactory singleton. |
org.hibernate.Session |
getSession()
getSession() returns a Hibernate Session |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
private static org.apache.commons.logging.Log log
instance
private static ConnectionFactory instance
sessionFactory
private org.hibernate.SessionFactory sessionFactory
ConnectionFactory
private ConnectionFactory()
- The Hibernate Configuration contains all the classes to be
persisted by Hibernate. For each class persisted, Hibernate will
expect to find a ClassName.hbm.xml file in the same location as the
class file. This XML file will define the mapping between the Java
object and the database.
To add additional classes to the configuration
Configuration cfg = new Configuration().
addClass(Foo.class).
addClass(Bar.class);
getInstance
public static ConnectionFactory getInstance()
- getInstance() returns the instance of the ConnectionFactory singleton.
Example call to retrieve session:
Session session = ConnectionFactory.getInstance().getSession();
- Returns:
- Instance of the
ConnectionFactory
singleton.
getSession
public org.hibernate.Session getSession()
- getSession() returns a Hibernate
Session
- Returns:
Session
retrieved from Hibernate SessionFactory
Copyright 2003