hibernate/hibernate-ogm — pull request #389 by gunnarmorling (2014-10-16 14:13:48+00:00)
Title: OGM-615, OGM-536: Avoiding re-reading entity tuples if feasible

(Based on top of https://github.com/hibernate/hibernate-ogm/pull/386, [see here](https://github.com/gunnarmorling/hibernate-ogm/compare/gunnarmorling:OGM-396...gunnarmorling:OGM-615) for the diff of this PR)

This change aims at reducing the number of `getTuple()` invocations issued by `OgmEntityPersister`. It is based on the recent ORM enhancement which allows to store additional statement in entity entries. We use it to store the original `Tuple` for an entity as returned by the first get/find. Upon entity update (and removal) we use that saved tuple instead of re-loading if that's feasible. Specifically, we don't re-load the tuple if it is not needed for the manual pseudo optimistic locking check and if the entity does not manage any inverse associations which would have to be updated as well.

Any feedback is welcome!