Class JPAWorkItemHandler

  • All Implemented Interfaces:
    org.kie.api.runtime.process.WorkItemHandler, org.kie.internal.runtime.Cacheable

    @Wid(widfile="JPADefinitions.wid",name="JPA",displayName="JPA",defaultHandler="mvel: new org.jbpm.process.workitem.jpa.JPAWorkItemHandler(\"persistenceUnit\", \"classloader\")",documentation="jpa-workitem/index.html",category="jpa-workitem",icon="JPA.png",parameters={@WidParameter(name="Type",runtimeType="java.lang.Object"),@WidParameter(name="Id",runtimeType="java.lang.Object"),@WidParameter(name="Entity",runtimeType="java.lang.Object"),@WidParameter(name="Action",required=true,runtimeType="java.lang.Object"),@WidParameter(name="Query",runtimeType="java.lang.Object"),@WidParameter(name="QueryParameters",runtimeType="java.lang.Object"),@WidParameter(name="QueryResults",runtimeType="java.lang.Object")},results=@WidResult(name="Result",runtimeType="java.util.Map"),mavenDepends=@WidMavenDepends(group="org.jbpm.contrib",artifact="jpa-workitem",version="7.62.0.Final"),serviceInfo=@WidService(category="JPA",description="Perform JPA operation",keywords="jpa,query,named,entity",action=@WidAction(title="Perform a JPA operation"),authinfo=@WidAuth(required=true,params="persistenceUnit",paramsdescription="Persistence Unit name",referencesite="")))
    public class JPAWorkItemHandler
    extends org.jbpm.process.workitem.core.AbstractLogOrThrowWorkItemHandler
    implements org.kie.internal.runtime.Cacheable
    A WorkItemHandler to perform JPA operations.
    An Action must be provided as an input parameter. The supported value for the Action parameters:
    • Create: Persist the object and return the attached entity. TO persist an object you must provide the object using the WIH parameter Entity
    • Update: Update an attached entity and returns the updated entity. You must provide the attached entity using the Entity WIH parameter.
    • Delete: Delete an attached entity. You must provide the attached entity using the Entity WIH parameter.
    • Get: Get an entity by ID. You must provide the return type using the Type parameter with the FQN of the target class and the ID using the Id parameter.
    • Query: Executes a named query and return the list of results (if any). The query must be provided using the Query input parameter and you may provide query parameters in the form of a Map with key String and value Object using the QueryParameters WIH input parameter. The result of the query is put on the output parameter QueryResults.
    When registering the WIH in the deployment descriptor, you must provide the classloader where your mapped entities are and the name of the persistence unit you configured in persistence.xml.