« Granularity of types | Main | Deleting code gives me a warm fuzzy feeling... »

Contextual Sessions in Hibernate

Somehow I missed this new feature in Hibernate 3.0.

Contextual sessions means that you can ask the SessionFactory for the current session. It will then return the session associated with your current JTA transaction. Of course, you need to have a JTA transaction, but that's not that big a deal. (For example, transactions with EJBs are JTA based)

This means that you don't need to pass the current session around in order to get access to it; you simply ask the SessionFactory. Of course, you need to get at the session factory - that can be done via JNDI very easily. And, of course, the session factory is threadsafe, whereas the session isn't.

Comments (1)

Michael:

Yet another reason to love hibernate 3 !

Post a comment


About

This page contains a single entry from the blog posted on April 13, 2005 10:32 AM.

The previous post in this blog was Granularity of types.

The next post in this blog is Deleting code gives me a warm fuzzy feeling....

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.35