Possible bug with deferSessionClose.

  • Eric Van Dewoestine

    first off, i'm glad i found this project.  i was very close to switching to spring before i found your contributions which fill a core portion of the void between the 2 frameworks.  I think you need to convince Howard to include a link to your project on the "Related Projects" portion of his site.

    Back on subject...  i did however run into a couple of issues that i beleive are bugs.

    I submitted a report and patch (http://sourceforge.net/tracker/index.php?func=detail&aid=1172232&group_id=123789&atid=697586)

    This solved the issue for me and appears to be working great so far.

    • Eric Van Dewoestine

      i've come across another issue with the code to defer session closing.

      Each transactional method call on a service results in a new hibernate Session.  Without defering the closing of the Session this is fine as each session will be closed upon method completion.

      However, with the defer flag set, each method still gets its own Session, but instead they are all left open until thread cleanup!  Luckily hibernate catches this fact and will throw an exception when it realizes it, but unfortunatly it doesn't realize it until two seperate methods each with there own transaction attempt to access the same data.

      For instance...
        If method A has a transaction and inserts some data and has its transaction committed, under the "defer" path it's session will still be open.
        Then method B comes along and selects the data that method A inserted.  Method B has its own Session and will attempt to load that data into it.  However hibernate sees that this data is already loaded in the Session for method A (Session still open), and refuses the let method B associate the data with its Session (since of course this could result in stale data in one of the Sessions).

      I'm attempting to solve the issue now by forcing the same Session to be used for all methods, where each method can still get its own transaction.  I'll post a patch when i make the change.

      • Jean-Francois Poilpret

        Hello Eric,

        first of all, sorry for my late answer, but I am far away from home currently (and this will last one month more...) and I don't often have time nor possibility to check what happens on hivetranse.

        I did not have time yet to check the original bug you reported, I will do this in the next few days hopefully.

        However, for the remark in your last mail, I have doubts: you say you would like to use several different transactions with one hibernate session, as far as I remember Hibernate does not allow that (this is why I created one Session per method, or more exactly, one Session per set of methods belonging to one transaction scope, depending on transaction demarcation property of your services).

        Anyway, if you find something interesting, just let me know.

        Thank you for your support.

            Jean-Francois, HiveTranse Team

    • Eric Van Dewoestine

      updated the original bug with a new patch that seems to solve these issues.

    • Eric Van Dewoestine

      Ah, i was a little curious how often you come on here... that explains it :).

      As for the multple transactions per session, this seems to be a topic of discussion among the hibernate community, but it is indeed possible.
      Here is a wiki page devoted to the subject (http://hibernate.org/168.html)
      I beleive that the "session-per-request-with-multiple-transactions pattern" is what's relevent in this situation.

      let me know what you think.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks