2 Replies Latest reply on May 19, 2011 5:26 AM by Heiko Tappe

    Get hibernate session for own query

    Heiko Tappe Newbie

      I am using jBPM 4.3 (embedded in war, working with JPA) and I need to support multiple tenants. So I prefix all idents with a tenant ident.

      Ok so far. But when I need to query jBPM (TaskQuery, ProcessInstanceQuery) I can't add the prefix.

      So I think I have to create/execute the queries on my own. Trying to do so I run into "errors" like:

       

      [org.hibernate.hql.QuerySplitter] no persistent classes found for query class:

      select processInstance from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance where processInstance.parent is null and processInstance.key like '1T%'

       

      This is probably due to using the hibernate session of the EntityManager!?

       

      How do I have to query jBPM from within my JPA environment? How to get the correct session for not running into the problems mentioned above?

       

      Any idea?

       

      --Heiko

        • 1. Get hibernate session for own query
          Heiko Tappe Newbie

          BTW, when I try to add (the missing?) mappings to the JPA persistence unit via

           

           

          <mapping-file>jbpm.repository.hbm.xml</mapping-file>

          <mapping-file>jbpm.execution.hbm.xml</mapping-file>

          <mapping-file>jbpm.history.hbm.xml</mapping-file>

          <mapping-file>jbpm.task.hbm.xml</mapping-file>

           

          I run into an exception:

           

          java.lang.UnsupportedOperationException: any not supported yet

           

          --Heiko

          • 2. Re: Get hibernate session for own query
            Heiko Tappe Newbie

            The following code seems to work for me:

             

            EnvironmentImpl environment = EnvironmentImpl.getCurrent();

            if (environment == null) {

                 environment = ((EnvironmentFactory) processEngine).openEnvironment();

            }

            Session session = environment.get(Session.class);

             

            But is this the way to go? If so, do I have to care about "closing" the environment?

             

            --Heiko