Patrick Haller created OLINGO-1113:
--------------------------------------
Summary: JPAProcessorImpl.readEntity() to use entityManager.find()
instead of dynamic query
Key: OLINGO-1113
URL: https://issues.apache.org/jira/browse/OLINGO-1113
Project: Olingo
Issue Type: Improvement
Components: odata2-jpa
Affects Versions: V2 2.0.8
Reporter: Patrick Haller
The semantics of the entity manager session is that repetitive calls to
entityManager.find( PK ) will return the very same object instance from the
session cache. Transient changes are NOT flushed to persistence before as JPA
already knows it can return a consistent state. Hence in scenarios where there
are repetitive reads on the same entity or where transient changes are
accumulated for bulk INSERT / bulk UPDATE, performance can be significantly
better than with the current dynamic JPQL query.
These scenarios typically involve non-trivial entity modifications (deep
update, deep insert, or linking inserted entities to parent entities) in
business logic, JSR-303 bean validation patterns in conjunction with, etc.
I would propose to check if JPAProcessorImpl.readEntity() can use
entityManager.find() instead of a dynamic query. This would resolve data
integrity issues with query.getResultList() returning a 2nd copy of the entity
instead of returning the very same instance.
The explicit em.flush() calls in process(DeleteUriInfo) and processUpdate()
should theoretically not be necessary.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)