3 Replies Latest reply on Feb 5, 2008 6:09 PM by twiceknightly

    concurrency question

    twiceknightly

      Hi,

      I want to write a plugin that I can call to persist my domain objects from within an action. I want to build on the jbpm hibernate code so that my updating of domain objects happens within the same transaction/hibernate session as the jbpm stuff. Will something like the following bit of code get me the hibernate session for the current thread?

      JbpmConfiguration.getInstance().getCurrentJbpmContext().getPersistenceService().getSession()

      Is there any concurrency concerns? The reason I ask is the way the current code uses thread locals. My understanding is that there is a jbpmContext per thread via a thread local in JbpmConfiguration.

      cheers!

        • 1. Re: concurrency question
          kukeltje

          We use it the other way around. Persisting the domain objects in their session and pass this session to the jbpm context. Not sure if it will work in your situation, but it does in ours.

          • 2. Re: concurrency question
            twiceknightly

             

            "kukeltje" wrote:
            We use it the other way around. Persisting the domain objects in their session and pass this session to the jbpm context. Not sure if it will work in your situation, but it does in ours.


            Yes I thought about that but in that case isn't there essentially two layers of hibernate helper code to get SessionFactory, session etc? i.e. your code and then the jbpm code? I thought that the way I suggested would reuse the fairly generic code already there. Also I presume that you will also need to use a thread local to hold a hibernate session for each thread?

            So you just call getCurrentJbpmContext at some point and then set the session on it?

            Also in terms of managing Hibernate config do you add your domain object mappings on the end of the jbpm mappings?

            Thanks for you help.

            • 3. Re: concurrency question
              twiceknightly

               

              "kukeltje" wrote:
              We use it the other way around. Persisting the domain objects in their session and pass this session to the jbpm context. Not sure if it will work in your situation, but it does in ours.


              One last thing ... did you write yours as a jbpm service?