aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate Tutorial Chapter 1 Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Tutorial Chapter 1 Problem" Watch "Hibernate Tutorial Chapter 1 Problem" New topic
Author

Hibernate Tutorial Chapter 1 Problem

kayanaat sidiqui
Ranch Hand

Joined: Sep 04, 2008
Posts: 122
Hi to all,
Well i am reading hibernate 3.2.2 tutorial.
Going through these web pages i came to know that we should use session as "Thread Bound Programming" that means one session per thread.
But when i was going through 1.3.3(Working the association), there is concept of detached objects and hence session opened and closed twice as per requirement. I want to know is it again one session per thread or what?

Thanks in advance.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Yup, even though you're opening and closing Sessions, you still have the Hibernate Session itself bound to the thread, or ThreadLocal context.

-Cameron McKenzie
Ketan Parekh
Greenhorn

Joined: Sep 15, 2005
Posts: 20
I am not able to open scja.com
ntumba lobo
Ranch Hand

Joined: Oct 21, 2008
Posts: 180

Yup, even though you're opening and closing Sessions, you still have the Hibernate Session itself bound to the thread, or ThreadLocal context.


From HibernateUtil.java



That means when we close a hibernate session, the session is not kept in the threadLocal with threadSession.set(null); , or I misunderstand something...
[ October 28, 2008: Message edited by: ntumba lobo ]

SCJP 5 , SCWCD 5, SCEA 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Tutorial Chapter 1 Problem