Results 1 to 4 of 4

Thread: Transaction mgmt - am I missing something?

  1. #1

    Default Transaction mgmt - am I missing something?

    Hi,

    I'm developing a spring/struts2/hibernate app, and deploying on tomcat.

    I'm using tx:annotation-driven, and marking my service methods with @Transactional. I was under the impression that this is binding me to a sesion context. in one of my service methods, I have some persistent object (which was retrieved from a dao, using an injected session factory), but when I'm accessing a collection, I still get the hibernate lazy instansiation exception (no session or session was closed). do I need to do anything else to have a session to work with?

    Thanks

  2. #2

    Default more details

    Hi,

    (moderator, you can delete the root post and put this one instead)

    My problem now is a little more focused.

    I'm using annotation driven transactions. I have a transactional service method, which accept a dettached object from the fromt end.

    if I'm using session.merge to re-attache my object, I get a lazy instantiation exception when asking a 'lazy' collection.

    If I'm re-reading the object by Id, everything seems to work.

    does this behaviour make sense?

    Thanks in advance

  3. #3
    Join Date
    Nov 2009
    Posts
    6

    Default See session in view pattern

    Not sure about exact problem you are facing, but I will recommend you to google for "Session In View" pattern, to overcome with lazy init and detached objects problems.

  4. #4
    Join Date
    Sep 2005
    Location
    USA
    Posts
    26

    Default

    Good question - you probably know about the docs already

    https://www.hibernate.org/42.html

    http://static.springsource.org/sprin...on-declarative

    But try using the OpenSessionInViewFilter

    http://static.springsource.org/sprin...iewFilter.html -- google for configuration details, it's just a filter in your web.xml that attaches the HBM session as a threadlocal, as I recall, and closes after Filter processing is complete. Seems to work for most people, but I am not sure how well it behaves well with JTA. Having issues there myself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •