Loading
Best possible create Hibernate Session

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  What is the best possible way to maintain or create the Hibernate Session ?


Ans)

Hibernate stongly recomand not use "session-per-operation antipattern",  meaning do
not open a new Session per each operation in a Business Transaction.

Please use the most common pattern in a multi-user client/server application is
session-per-request. A new Hibernate Session is opened, and all database operations are
executed in this unit of work.

Hibernate provides built-in management of the "current session" to simplify this pattern.
Start a transaction when a server request has to be processed, and end the transaction before
the response is sent to the client. Common solutions are ServletFilter, AOP interceptor with
a pointcut on the service methods, or a proxy/interception container.

Other best way is to get the "HiberanteSession and store in Thread Local" and fetch from Thread
local before open a new Session for any given Request.



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Best possible create Hibernate Session


Best possible create Hibernate Session

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free