| Author |
Hiberante - differnce between methods from SessionFactory - openSession() and getCurrentSession()
|
Witold Marshal
Ranch Hand
Joined: Feb 05, 2012
Posts: 48
|
|
I don't understand the difference between those two mtehods in the way that it is described in documentation.
As I know both method create Session object.
I suspect from what I have read that:
"getCurrentSession()" is only allowed in container calls during JTA transaction (?) and "openSession()" is valid outside JTA transaction and container (in utility class) (?)
Is that true?
|
 |
Manuel Petermann
Ranch Hand
Joined: Jul 19, 2011
Posts: 175
|
|
openSession() is actually creating a new session every time it is called.
getCurrentSession() returns a session associated with the current context, that may or may not be a jta transaction. It may be a new one or the one previously used in the same context.
At least thats how i understand the documentation.
|
Please correct my English.
|
 |
Witold Marshal
Ranch Hand
Joined: Feb 05, 2012
Posts: 48
|
|
|
Thanks, it seems reasonable.
|
 |
 |
|
|
subject: Hiberante - differnce between methods from SessionFactory - openSession() and getCurrentSession()
|
|
|