First of all please note I have posted the below question in
Stackoverflow and I have one answer there, but I am not sure about it because it seems like the member who answered also not much sure about his answer. Below is my question.
I am having a
JSP,
Servlet (Pure JSP, Servlet) application where it uses `Hibernate`. Below is a `Hibernate` implementation class for a one table.
DesignationImpl.java
Below is the service class which calls to the above class.
DesignationService .java
And the servlets call them like below.
As you can see, there is a bad thing happening there, that is, the servlets are creating new `SessionFactory` instances every time it executes.I am having `Driver#Connect` issues and I guess this might be the reason for it.
I read stackoverflow posts and some seems to be suggesting the use of only one `SessionFactory` for the entire application. If it is suitable, then how can I do it? Maybe make a singleton class like below and use it in my implementation classes?
But then what about threads? Servlets are multi threaded isn't it?