Hi there,
When we create a SessionFactory to get session, we used to do this:
Code:
public class HibernateSessionFactory{
private static SessionFactory sf = null;
public static synchronized Session get Session() throws HibernateExceptuion{
Configuration conf = null;
if (sf == null) {
conf = new Configuration().addClass(...);
sf = conf.buildSessionFactory();
}
return sf.openSession();
}
Does anyone know why we are using Static function, and variable here?
I thought maybe we only initialize SessionFactory once, but I am not really sure, please help me!
Thanks all a lot!