Announcement Announcement Module
Collapse
No announcement yet.
Hi Everyone Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hi Everyone

    I'm new to hibernate and spring.
    I've created DAOs that use HibernateTemplate and my services use proxy for transaction support.
    The problem that I'm facing is that if I want to set an entity member to Lazy fetch mode I get an error that the session is closed.
    What is the correct way for me to enable this feature?

    Thanks,
    Mike.

  • #2
    If you search on the forum with the exception you are getting, you'll find lots of answers. OpenSessionInView Filter/Interceptor is one approach. Reattaching the entity to the Session to retrieve more data is one and eager loading is another.
    Last edited by karldmoore; Aug 27th, 2007, 04:06 PM.

    Comment


    • #3
      Thanks karldmoore, one more option I read

      I did do a lot of searching.
      I would like to know if I can bother you with an option I found.
      Assuming that I do not want to put every member as EAGER and that I do not want to open a session on each request.
      Since I either get the entity members from a DAO (to which HibernateTemplate takes care of the session management issues) or a Service, wouldn't a wrapping of the relevant service method with transaction support (HibernateTransactionManager) be a correct solution?

      Hope my question is clear.
      Thanks,
      Mike.

      Comment


      • #4
        Yes, adding the transaction at the service layer would be a great idea. It's a pretty standard approach. Obviously the Session and therefore lazy loading is only possible for the lifetime of the transaction (if you aren't using OSIV), for other transactions you'd have to reattach the entity.
        Last edited by karldmoore; Aug 27th, 2007, 04:06 PM.

        Comment


        • #5
          Thanks for the help karldmoore

          Thanks

          Mike

          Comment


          • #6
            Not a problem, glad to help! If you have any more questions just post back and I'll try to help.
            http://www.springframework.org/docs/...decl-explained
            http://www.martinfowler.com/eaaCatal...viceLayer.html
            Last edited by karldmoore; Aug 27th, 2007, 04:06 PM.

            Comment

            Working...
            X