In OgmEntityPersister#insert(Serializable id, Object[] fields, Object object, SessionImplementor session) we currently do a tuple read prior to the insert in order to detect the insertion of duplicates.
This can be avoided, depending on the capabilities of the datastore:
-
It doesn't allow for the insertion of another record with an already existing id (raises an exception)
-
If a store only knows "upsert" semantics but can report back whether an upsert was actually an update to an existing record and allows for a rollback of such change
We'd have to enhance the grid dialect contract to allow stores signalling their capabilities here. The current get-prior-read causes a significantly lower insert performance e.g. for MongoDB (about 1/4th when using batching).
|