I am using Hibernate 3 version for my Application .
While going through tutorials on Hibernate, I found out that, SessionFactory
should be created only once for the application.
So for this I have decided to use a static block inside a class and a static method to return this as shown.
public class SessionFactoryInitiliaztion {
static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Exception x) {
x.printStackTrace();
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Where exactly do I need to close this sessionFactory
object , so that it resales the memory ?