Joined: Mon Jun 25, 2012 7:33 am Posts: 4
|
I am new in Hibernate and some things (like Session Contexts) are not clear for me. I understand all issues connected with Persistence Context in JPA but here (in Hibernate), the description from documenation about Session Contexts is not comprehensive enouhg.
In documenation of Hibernate 3.6 there are mentioned 3 types of SessionContexs: 1. org.hibernate.context.internal.JTASessionContext
2. org.hibernate.context.internal.ThreadLocalSessionContext
3. org.hibernate.context.internal.ManagedSessionContext
As I was looking through some examples of hibernate.cfg.xml configuration files I saw that "thread" context is applied (in cfg.xml) in the most cases.
In documenattion of Hiberante 4.1 there are mentione d only too types of context scope:
1. org.hibernate.context.internal.JTASessionContext
2. org.hibernate.context.internal.ManagedSessionContext
A. Does it mean that org.hibernate.context.internal.ThreadLocalSessionContext is discarded in Hibernate 4.1? Is it not allowed to use it in Hib. 4.1? I have also some other questions:
B. If the property connected with Context ( <property name="current_session_context_class">) in cfg.xml file is not set which one is used as deafult (for both verions of Hib. 3.x and 4.x )?
C. Which Session Context should I set for appliction working in J2SE environment (for both verions of Hib. 3.x and 4.x )? I assume that JTASessionContext is inappropriate ?
D. ManagedSessionContext is not clear for me. I don't understand the usage of "bind()" and "unbind()". It is written (in docs) that "bind()": "Binds the given session to the current context for its session factory." Does it mean that there is a one SessionContext for SessionFactory and it can be used in many transaction and can be bind to any Session object that was created by this Session Factory? The end of the transaction doesn't clear it and close it?
If you can answer for any of those question I will be grateful.
|
|