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.