2 Replies Latest reply on Oct 18, 2005 5:53 PM by alal007

    inserting into my tables from action code

    alal007

      From action code of some node, I have to insert/update/delete some record into some of my table. What is the recommended way of achieving this
      DO i Need to create hibernate mapping for my table?
      is it possible to get handle to connection from context which is passed to action handler and create sql statement and execute/commit sql ?
      If above is possible, is there an issue with doing that?

      Appreciate any help

        • 1. Re: inserting into my tables from action code
          aguizar

           

          DO i Need to create hibernate mapping for my table?

          No. We encorauge you to do so, for uniformity (jBPM already uses Hibernate) and maintainability (avoid CUD statements all around).
          is it possible to get handle to connection from [execution] context ?

          Not exactly from the context, but from a thread local encapsulated in class JbpmSession:
          JbpmSession jbpmSession = JbpmSession.getCurrentJbpmSession();
          Connection jdbcConnection = jbpmSession.getConnection();
          /* now do stuff with the jdbcConnection */

          Note that in order for this to work, a jBPM session must have been opened earlier in the current thread. This is the case when you load a token from the database and then signal it.
          As an alternative to using the connection directly, you can use Hibernate's native SQL support.
          is there an issue with doing that?

          None, just remember you have to manage your statements but not the connection.

          • 2. Re: inserting into my tables from action code
            alal007

            thanks for answering my question.