Interface JPACUDRequestHandler
- All Known Implementing Classes:
JPAAbstractCUDRequestHandler,JPAExampleCUDRequestHandler
public interface JPACUDRequestHandler
-
Method Summary
Modifier and TypeMethodDescriptioncreateEntity(JPARequestEntity requestEntity, javax.persistence.EntityManager em)Hook to create an entity.voiddeleteEntity(JPARequestEntity requestEntity, javax.persistence.EntityManager em)updateEntity(JPARequestEntity requestEntity, javax.persistence.EntityManager em, org.apache.olingo.commons.api.http.HttpMethod httpMethod)Hook to handle all request that change an existing entity.voidvalidateChanges(javax.persistence.EntityManager em)Hook that is called after all changes of one transaction have been processed.
-
Method Details
-
deleteEntity
void deleteEntity(JPARequestEntity requestEntity, javax.persistence.EntityManager em) throws ODataJPAProcessException- Parameters:
requestEntity-em-- Throws:
ODataJPAProcessException
-
createEntity
Object createEntity(JPARequestEntity requestEntity, javax.persistence.EntityManager em) throws ODataJPAProcessExceptionHook to create an entity. Transaction handling is done outside to guarantee transactional behavior of change sets in batch requests. This method has to return the newly create entity even so validateChanges is implemented.- Parameters:
requestEntity-em-- Returns:
- The newly created instance or map of created attributes including default and added values following the same rules as jpaAttributes
- Throws:
ODataJPAProcessException
-
updateEntity
JPAUpdateResult updateEntity(JPARequestEntity requestEntity, javax.persistence.EntityManager em, org.apache.olingo.commons.api.http.HttpMethod httpMethod) throws ODataJPAProcessExceptionHook to handle all request that change an existing entity. This includes update and upsert on entities, updates on properties and values, updates on relations as well as deletions on values and properties.
Note: Deviating from the OData standard changes on collection properties will be provided as PATCH, as it is from an entity point of view is the partial change. An implementation needs to take care that all elements of the collection are exchanged!- Parameters:
requestEntity- SeeJPARequestEntityem- Instance of an entity manager with an open transaction.httpMethod- The original http method: PATCH, PUT, DELETE- Returns:
- The response describes the performed changes (Created or Updated) as well as the result of the operation. It must not be null. Even if nothing was changed => update is idempotent
- Throws:
ODataJPAProcessException- See Also:
- OData Version 4.0 Part 1 - 11.4.3 Update an Entity
OData Version 4.0 Part 1 - 11.4.4 Upsert an Entity
OData Version 4.0 Part 1 - 11.4.6 Modifying Relationships between Entities
OData Version 4.0 Part 1 - 11.4.9 Managing Values and Properties Directly
-
validateChanges
Hook that is called after all changes of one transaction have been processed. The method shall enable a check of all modification within the new context. This can be imported if multiple entities are changes with the same request (batch request or deep-insert) and consistency constrains exist between them.- Throws:
ODataJPAProcessException
-