Class JPAAbstractCUDRequestHandler
java.lang.Object
com.sap.olingo.jpa.processor.core.api.JPAAbstractCUDRequestHandler
- All Implemented Interfaces:
JPACUDRequestHandler
- Direct Known Subclasses:
JPAExampleCUDRequestHandler
-
Constructor Summary
Constructors -
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.
-
Constructor Details
-
JPAAbstractCUDRequestHandler
public JPAAbstractCUDRequestHandler()
-
-
Method Details
-
deleteEntity
public void deleteEntity(JPARequestEntity requestEntity, javax.persistence.EntityManager em) throws ODataJPAProcessException- Specified by:
deleteEntityin interfaceJPACUDRequestHandler- Throws:
ODataJPAProcessException
-
createEntity
public Object createEntity(JPARequestEntity requestEntity, javax.persistence.EntityManager em) throws ODataJPAProcessExceptionDescription copied from interface:JPACUDRequestHandlerHook 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.- Specified by:
createEntityin interfaceJPACUDRequestHandler- Returns:
- The newly created instance or map of created attributes including default and added values following the same rules as jpaAttributes
- Throws:
ODataJPAProcessException
-
updateEntity
public JPAUpdateResult updateEntity(JPARequestEntity requestEntity, javax.persistence.EntityManager em, org.apache.olingo.commons.api.http.HttpMethod httpMethod) throws ODataJPAProcessExceptionDescription copied from interface:JPACUDRequestHandlerHook 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!- Specified by:
updateEntityin interfaceJPACUDRequestHandler- 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
Description copied from interface:JPACUDRequestHandlerHook 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.- Specified by:
validateChangesin interfaceJPACUDRequestHandler- Throws:
ODataJPAProcessException
-