Announcement Announcement Module
No announcement yet.
OpenSessionInViewFilter - open connections Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenSessionInViewFilter - open connections

    Hi Folks -
    I'm in the middle of upgrading our apps to Spring 1.2 and Hibernate 3.0.3. I thought I would take another stab at implementing OpenSessionInViewFilter since hibernate 3.0 uses lazy="true" by default everywhere...

    We are using:
    • * WebLogic 8.1 sp3
      * JTATransactionManager for spring managed transactions
      * some CMT EJBs with required transactions

    When I specify singleSession = false for the filter, I get proper behavior, but the deferred session close means that ALL sessions remain open until the filter completes - which means 1 request may use many connections.

    What I need, is for some non-transactional session to be used to load read-only/lazy objects, and open separate sessions for transactional object use.

    We cannot use the same session in multiple transactions (or after a transaction commits/rollsback) due to JTA/WebLogic constraints.

    Is the only alternative to use a single JTA tx per http request?


  • #2
    AFAIK, unless you mark your methods as transactional, no transaction will made even inside a CMT environment but I may be mistaken - place logging on Hibernate Transaction.
    If you need specific behavior you can extends the OpenSessionFilterInView and to customize it to allow a better configuration that fits your needs.
    For example you can parse the request and depending on the path create transactional or non-trasactional sessions.