org.jbpm.process.audit

## Class JPAService

- java.lang.Object
- - org.jbpm.process.audit.JPAService

- Direct Known Subclasses:
    JPAAuditLogService

      public class JPAService
      extends Object

  The idea here is that we have a entity manager factory (similar to a session factory) that we repeatedly use to generate an entity manager (which is a persistence context) for the specific service command. To start with, not all of our entities contain LOB's ("Large Objects" see https://en.wikibooks.org/wiki/Java_Persistence/Basic_Attributes#LOBs.2C_BLOBs .2C_CLOBs_and_Serialization) which sometimes necessitate the use of tx's even in read situations. However, we use transactions here none-the-less, just to be safe. Obviously, if there is already a running transaction present, we don't do anything to it. At the end of every command or operation, make sure to close the entity manager you've been using -- which also means that you should detach any entities that might be associated with the entity manager/persistence context. After all, this is a service which means our philosophy here is to provide a real interface, and not a leaky absraction. (https://en.wikipedia.org/wiki/Leaky_abstraction)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected PersistenceStrategy` | `persistenceStrategy`
    `protected String` | `persistenceUnitName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JPAService(javax.persistence.EntityManagerFactory emf)`
    `JPAService(javax.persistence.EntityManagerFactory emf, PersistenceStrategyType type)`
    `JPAService(org.kie.api.runtime.Environment env, PersistenceStrategyType type)`
    `JPAService(org.kie.api.runtime.Environment env, String persistenceUnitName)`
    `JPAService(String persistenceUnitName)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `closeEntityManager(javax.persistence.EntityManager em, Object transaction)`
    `void` | `dispose()`
    `<T> List<T>` | `executeQuery(javax.persistence.Query query, javax.persistence.EntityManager em, Class<T> type)`
    `protected javax.persistence.EntityManager` | `getEntityManager()`
    `String` | `getPersistenceUnitName()`
    `protected Object` | `joinTransaction(javax.persistence.EntityManager em)`
    `void` | `setPersistenceUnitName(String persistenceUnitName)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### persistenceStrategy

          protected PersistenceStrategy persistenceStrategy

    - #### persistenceUnitName

          protected String persistenceUnitName

  - ### Constructor Detail

    - #### JPAService

          public JPAService(String persistenceUnitName)

    - #### JPAService

          public JPAService(org.kie.api.runtime.Environment env,
                            PersistenceStrategyType type)

    - #### JPAService

          public JPAService(org.kie.api.runtime.Environment env,
                            String persistenceUnitName)

    - #### JPAService

          public JPAService(javax.persistence.EntityManagerFactory emf)

    - #### JPAService

          public JPAService(javax.persistence.EntityManagerFactory emf,
                            PersistenceStrategyType type)

  - ### Method Detail

    - #### setPersistenceUnitName

          public void setPersistenceUnitName(String persistenceUnitName)

    - #### getPersistenceUnitName

          public String getPersistenceUnitName()

    - #### dispose

          public void dispose()

    - #### getEntityManager

          protected javax.persistence.EntityManager getEntityManager()

    - #### joinTransaction

          protected Object joinTransaction(javax.persistence.EntityManager em)

    - #### closeEntityManager

          protected void closeEntityManager(javax.persistence.EntityManager em,
                                            Object transaction)

    - #### executeQuery

          public <T> List<T> executeQuery(javax.persistence.Query query,
                                          javax.persistence.EntityManager em,
                                          Class<T> type)

Copyright © 2001–2019 JBoss by Red Hat. All rights reserved.