I'm learning java servlets and hibernate. I have separate working examples of each and am now trying to merge the hibernate example into an http servlet.
My simple hibernate sample starts with this code
factory = new AnnotationConfiguration().configure().buildSessionFactory();
Session session = factory.openSession();
When the http servlet is called via an http get, I understand it's calling the constructor first, then the doGet method.
Now my question (please be easy on me as I'm a newbie here): what is the accepted way to call the hibernate initialization code from the servlet? Do I put the above initialization code in the constructor method?
init()method or within aServletContextListener.