Package org.jbpm.runtime.manager.impl.mapper

## Class JPAMapper

- java.lang.Object
- - org.jbpm.runtime.manager.impl.mapper.InternalMapper
  - - org.jbpm.runtime.manager.impl.mapper.JPAMapper

- All Implemented Interfaces:
    `org.kie.internal.runtime.manager.Mapper`

      public class JPAMapper
      extends InternalMapper

  Database based mapper implementation backed by JPA to store the context to `KieSession` id mapping. It uses the `ContextMappingInfo` entity for persistence.
  See Also:
    `ContextMappingInfo`

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `JPAMapper​(javax.persistence.EntityManagerFactory emf)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected ContextMappingInfo` | `findContextByContextId​(org.kie.api.runtime.manager.Context context, String ownerId, javax.persistence.EntityManager em)` |
    `Object` | `findContextId​(Long ksessionId, String ownerId)` |
    `List<String>` | `findContextIdForEvent​(String eventType, String ownerId)` |
    `List<Long>` | `findKSessionToInit​(String ownerId)` |
    `Long` | `findLogMapping​(org.kie.api.runtime.manager.Context<?> context, String ownerId)` | Finds ksession for given context
    `Long` | `findMapping​(org.kie.api.runtime.manager.Context context, String ownerId)` |
    `org.kie.api.runtime.manager.Context` | `getProcessInstanceByCorrelationKey​(org.kie.internal.process.CorrelationKey correlationKey, javax.persistence.EntityManager em)` |
    `void` | `removeMapping​(org.kie.api.runtime.manager.Context context, String ownerId)` |
    `protected <T> org.kie.api.runtime.manager.Context<T>` | `resolveContext​(org.kie.api.runtime.manager.Context orig, javax.persistence.EntityManager em)` |
    `void` | `saveMapping​(org.kie.api.runtime.manager.Context context, Long ksessionId, String ownerId)` |

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

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

- - ### Constructor Detail

    - #### JPAMapper

          public JPAMapper​(javax.persistence.EntityManagerFactory emf)

  - ### Method Detail

    - #### saveMapping

          public void saveMapping​(org.kie.api.runtime.manager.Context context,
                                  Long ksessionId,
                                  String ownerId)

    - #### findMapping

          public Long findMapping​(org.kie.api.runtime.manager.Context context,
                                  String ownerId)

    - #### findLogMapping

          public Long findLogMapping​(org.kie.api.runtime.manager.Context<?> context,
                                     String ownerId)

      Description copied from class: `InternalMapper`
      Finds ksession for given context
      Overrides:
        `findLogMapping` in class `InternalMapper`
      Parameters:
        `context` - instance of the context
      Returns:
        ksession identifier when found otherwise null

    - #### removeMapping

          public void removeMapping​(org.kie.api.runtime.manager.Context context,
                                    String ownerId)

    - #### resolveContext

          protected <T> org.kie.api.runtime.manager.Context<T> resolveContext​(org.kie.api.runtime.manager.Context orig,
                                                                              javax.persistence.EntityManager em)

    - #### findContextByContextId

          protected ContextMappingInfo findContextByContextId​(org.kie.api.runtime.manager.Context context,
                                                              String ownerId,
                                                              javax.persistence.EntityManager em)

    - #### getProcessInstanceByCorrelationKey

          public org.kie.api.runtime.manager.Context getProcessInstanceByCorrelationKey​(org.kie.internal.process.CorrelationKey correlationKey,
                                                                                        javax.persistence.EntityManager em)

    - #### findContextId

          public Object findContextId​(Long ksessionId,
                                      String ownerId)

    - #### findKSessionToInit

          public List<Long> findKSessionToInit​(String ownerId)

    - #### findContextIdForEvent

          public List<String> findContextIdForEvent​(String eventType,
                                                    String ownerId)

      Specified by:
        `findContextIdForEvent` in class `InternalMapper`