|Home |Login |Registration |Struts Step by Step Tutorial |Hibernate Step by Step Tutorial |Spring Step by Step Tutorial |JSP Step by Step Tutorial |JDBC Step by Step Tutorial |Web Services Step by Step Tutorial |EJB fundamentals | ORACLE Step by Step Tutorial | SCJP 5.0 and SCJP 6.0 Study Guide | SCWCD 5.0 Study Guide | SCJP Tips
Java mock test | SCJP mock test | SCJP DUMP | SCBCD mock test |Java online test exam | JSP online test | ORACLE online test | Hibernate online test | Servlet online test | Struts online test | EJB online test | C online test | C++ online test | Aptitude online test

Java interview questions | JSP interview questions | ORACLE interview questions | Hibernate interview questions | Servlet interview questions | Struts interview questions | JDBC interview questions | C/C++ interview questions | Spring interview questions | JMS interview questions | Informatica interview questions | EJB interview questions | OOPS and Design Pattern interview questions
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) JobsJobs and Walkins

 

Recent Questions

!!! Hibernate Frequently Asked Questions !!!

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

SCJP 1.5/1.6 Exam Kit

!!!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 : Apr 10 2012
Answer :


Answered By : null Replied Date : Apr 4 2012
Answer :


Answered By : null Replied Date : Mar 23 2012
Answer :


Answered By : null Replied Date : Mar 12 2012
Answer :


Answered By : null Replied Date : Feb 24 2012
Answer :


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


Answered By : null Replied Date : Jan 27 2012
Answer :


Answered By : null Replied Date : Jan 26 2012
Answer :


Answered By : null Replied Date : Jan 26 2012
Answer :


Answered By : null Replied Date : Jan 13 2012
Answer :


Answered By : null Replied Date : Jan 10 2012
Answer :


Answered By : null Replied Date : Jan 4 2012
Answer :


Answered By : null Replied Date : Dec 29 2011
Answer :


Answered By : null Replied Date : Dec 24 2011
Answer :


Answered By : null Replied Date : Dec 3 2011
Answer :


Answered By : null Replied Date : Nov 13 2011
Answer :


Answered By : null Replied Date : Oct 14 2011
Answer :


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


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


Answered By : null Replied Date : Sep 25 2011
Answer :


Answered By : null Replied Date : Sep 25 2011
Answer :


Answered By : null Replied Date : Aug 14 2011
Answer :


Answered By : null Replied Date : Aug 5 2011
Answer :


Answered By : null Replied Date : Aug 3 2011
Answer :


Answered By : null Replied Date : Jul 16 2011
Answer :


Answered By : null Replied Date : May 28 2011
Answer :


Answered By : null Replied Date : May 23 2011
Answer :


Answered By : null Replied Date : May 14 2011
Answer :


Answered By : null Replied Date : May 12 2011
Answer :


Answered By : null Replied Date : May 7 2011
Answer :


Answered By : null Replied Date : Apr 24 2011
Answer :


Answered By : null Replied Date : Apr 10 2011
Answer :


Answered By : null Replied Date : Apr 1 2011
Answer :


Answered By : null Replied Date : Mar 31 2011
Answer :


Answered By : null Replied Date : Mar 29 2011
Answer :


Answered By : null Replied Date : Mar 18 2011
Answer :


Answered By : null Replied Date : Mar 11 2011
Answer :


Answered By : null Replied Date : Feb 28 2011
Answer :


Answered By : null Replied Date : Feb 27 2011
Answer :


Answered By : null Replied Date : Feb 26 2011
Answer :


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


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


Answered By : null Replied Date : Feb 17 2011
Answer :


Answered By : null Replied Date : Feb 17 2011
Answer :


Answered By : null Replied Date : Feb 17 2011
Answer :


Answered By : null Replied Date : Feb 17 2011
Answer :


Answered By : null Replied Date : Feb 16 2011
Answer :


Answered By : null Replied Date : Feb 16 2011
Answer :


Answered By : null Replied Date : Feb 15 2011
Answer :


Answered By : null Replied Date : Feb 14 2011
Answer :


Answered By : null Replied Date : Feb 13 2011
Answer :


Answered By : null Replied Date : Feb 10 2011
Answer :


Answered By : null Replied Date : Feb 8 2011
Answer :


Answered By : null Replied Date : Feb 7 2011
Answer :


Answered By : null Replied Date : Feb 7 2011
Answer :


Answered By : null Replied Date : Feb 3 2011
Answer :


Answered By : null Replied Date : Feb 3 2011
Answer :


Answered By : null Replied Date : Feb 1 2011
Answer :


Answered By : null Replied Date : Jan 29 2011
Answer :


Answered By : null Replied Date : Jan 27 2011
Answer :


Answered By : null Replied Date : Jan 26 2011
Answer :


Answered By : null Replied Date : Jan 25 2011
Answer :


Answered By : null Replied Date : Jan 25 2011
Answer :


Answered By : null Replied Date : Jan 24 2011
Answer :


Answered By : null Replied Date : Jan 22 2011
Answer :


Answered By : null Replied Date : Jan 15 2011
Answer :


Answered By : null Replied Date : Jan 14 2011
Answer :


Answered By : null Replied Date : Jan 13 2011
Answer :


Answered By : null Replied Date : Jan 10 2011
Answer :


Answered By : null Replied Date : Dec 30 2010
Answer :


Answered By : null Replied Date : Dec 24 2010
Answer :


Answered By : null Replied Date : Dec 23 2010
Answer :


Answered By : null Replied Date : Dec 18 2010
Answer :


Answered By : null Replied Date : Dec 18 2010
Answer :


Answered By : null Replied Date : Dec 17 2010
Answer :


Answered By : null Replied Date : Dec 10 2010
Answer :


Answered By : null Replied Date : Dec 9 2010
Answer :


Answered By : null Replied Date : Dec 9 2010
Answer :


Answered By : null Replied Date : Dec 8 2010
Answer :


Answered By : null Replied Date : Dec 8 2010
Answer :


Answered By : null Replied Date : Dec 5 2010
Answer :


Answered By : null Replied Date : Dec 4 2010
Answer :


Answered By : null Replied Date : Dec 3 2010
Answer :


Answered By : null Replied Date : Dec 1 2010
Answer :


Answered By : null Replied Date : Nov 22 2010
Answer :


Answered By : null Replied Date : Nov 21 2010
Answer :


Answered By : null Replied Date : Nov 19 2010
Answer :


Answered By : null Replied Date : Nov 19 2010
Answer :


Answered By : null Replied Date : Nov 19 2010
Answer :


Answered By : null Replied Date : Nov 16 2010
Answer :


Answered By : null Replied Date : Nov 16 2010
Answer :


Answered By : null Replied Date : Nov 8 2010
Answer :


Answered By : null Replied Date : Oct 30 2010
Answer :


Answered By : null Replied Date : Oct 30 2010
Answer :


Answered By : null Replied Date : Oct 29 2010
Answer :


Answered By : null Replied Date : Oct 29 2010
Answer :


Answered By : null Replied Date : Oct 27 2010
Answer :


Answered By : null Replied Date : Oct 25 2010
Answer :


Answered By : null Replied Date : Oct 19 2010
Answer :


Answered By : null Replied Date : Oct 18 2010
Answer :


Answered By : null Replied Date : Oct 18 2010
Answer :


Answered By : null Replied Date : Oct 15 2010
Answer :


Answered By : null Replied Date : Oct 14 2010
Answer :


Answered By : null Replied Date : Oct 8 2010
Answer :


Answered By : null Replied Date : Oct 8 2010
Answer :


Answered By : null Replied Date : Oct 6 2010
Answer :


Answered By : null Replied Date : Oct 5 2010
Answer :


Answered By : null Replied Date : Sep 29 2010
Answer :


Answered By : null Replied Date : Sep 29 2010
Answer :


Answered By : null Replied Date : Sep 27 2010
Answer :


Answered By : null Replied Date : Sep 22 2010
Answer :


Answered By : null Replied Date : Sep 21 2010
Answer :


Answered By : null Replied Date : Sep 18 2010
Answer :


Answered By : null Replied Date : Sep 18 2010
Answer :


Answered By : null Replied Date : Sep 18 2010
Answer :


Answered By : null Replied Date : Sep 18 2010
Answer :


Answered By : null Replied Date : Sep 18 2010
Answer :


Answered By : null Replied Date : Sep 18 2010
Answer :


Answered By : null Replied Date : Sep 17 2010
Answer :


Answered By : null Replied Date : Sep 17 2010
Answer :


Answered By : null Replied Date : Sep 14 2010
Answer :


Answered By : null Replied Date : Sep 8 2010
Answer :


Answered By : null Replied Date : Sep 7 2010
Answer :


Answered By : null Replied Date : Sep 1 2010
Answer :


Answered By : null Replied Date : Sep 1 2010
Answer :


Answered By : null Replied Date : Aug 31 2010
Answer :


Answered By : null Replied Date : Aug 30 2010
Answer :


Answered By : null Replied Date : Aug 30 2010
Answer :


Answered By : null Replied Date : Aug 26 2010
Answer :


Answered By : null Replied Date : Aug 26 2010
Answer :


Answered By : null Replied Date : Aug 25 2010
Answer :


Answered By : null Replied Date : Aug 25 2010
Answer :


Answered By : null Replied Date : Aug 21 2010
Answer :


Answered By : null Replied Date : Aug 20 2010
Answer :


Answered By : null Replied Date : Aug 16 2010
Answer :


Answered By : null Replied Date : Aug 14 2010
Answer :


Answered By : null Replied Date : Aug 12 2010
Answer :


Answered By : null Replied Date : Aug 11 2010
Answer :


Answered By : null Replied Date : Aug 10 2010
Answer :


Answered By : null Replied Date : Aug 10 2010
Answer :


Answered By : null Replied Date : Aug 10 2010
Answer :


Answered By : null Replied Date : Aug 9 2010
Answer :


Answered By : null Replied Date : Aug 6 2010
Answer :


Answered By : null Replied Date : Aug 6 2010
Answer :


Answered By : null Replied Date : May 8 2012
Answer :


Answered By : null Replied Date : Jun 10 2012
Answer :


Answered By : null Replied Date : Jun 21 2012
Answer :


Answered By : null Replied Date : Jul 4 2012
Answer :


Answered By : null Replied Date : Jul 9 2012
Answer :


Answered By : null Replied Date : Jul 15 2012
Answer :


Answered By : null Replied Date : Jul 15 2012
Answer :


Answered By : null Replied Date : Aug 1 2012
Answer :


Answered By : null Replied Date : Aug 9 2012
Answer :


Answered By : null Replied Date : Sep 7 2012
Answer :


Answered By : null Replied Date : Oct 10 2012
Answer :


Answered By : null Replied Date : Nov 2 2012
Answer :


Answered By : null Replied Date : Nov 29 2012
Answer :


Answered By : null Replied Date : Dec 4 2012
Answer :


Answered By : null Replied Date : Dec 15 2012
Answer :


Answered By : null Replied Date : Dec 30 2012
Answer :


Answered By : null Replied Date : Jan 22 2013
Answer :


Answered By : null Replied Date : Mar 6 2013
Answer :


Answered By : null Replied Date : Mar 8 2013
Answer :


 

You can also contribute to this answer:

Your Name:
Answer:

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

The information you are posting should be related to java and ORACLE technology. Not political.