1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)
 

Recent Questions

!!! Hibernate Frequently Asked Questions !!!

What is a Hibernate Session? Can you share a session object between different theads?

!!!Answer!!!- From Technical Expert

Session is a light weight and a non-threadsafe object (No, you cannot share it between threads) that represents a single unit-of-work with the database. Sessions are opened by a SessionFactory and then are closed when all work is complete. Session is the primary interface for the persistence service. A session obtains a database connection lazily (i.e. only when required). To avoid creating too many sessions ThreadLocal class can be used as shown below to get the current session no matter how many times you make call to the currentSession() method.

?
public class HibernateUtil {
?
public static final ThreadLocal local = new ThreadLocal();

public static Session currentSession() throws HibernateException {
Session session = (Session) local.get();
//open a new session if this thread has no session
if(session == null) {
session = sessionFactory.openSession();
local.set(session);
}
return session;
}
}

Answered By : null Replied Date : Oct 24 2013
Answer :


Answered By : null Replied Date : Oct 21 2013
Answer :


Answered By : null Replied Date : Oct 13 2013
Answer :


Answered By : null Replied Date : Feb 20 2014
Answer :


Answered By : null Replied Date : May 22 2014
Answer :


Answered By : null Replied Date : May 22 2014
Answer :


Answered By : null Replied Date : Sep 5 2014
Answer :


Answered By : null Replied Date : Nov 14 2014
Answer :


Answered By : null Replied Date : Jun 19 2015
Answer :


Answered By : null Replied Date : Feb 25 2016
Answer :


Answered By : null Replied Date : Apr 18 2016
Answer :


 

You can also contribute to this answer:

Your Name:
Answer:

 
Ask Question and get answer from Expert.
View Answers List from Expert.

Reviews and Comments


PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2016


About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy