-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Mutation
-
None
-
None
-
None
-
None
-
None
-
None
-
None
StatelessSession.upsert on a @Version entity is rejected (TODO-HIBERNATE-216 in MongoDialect). The upsert filter carries the optimistic-lock binding, so a stale version matches nothing and the server attempts an insert, which fails with E11000 on _id instead of Hibernate reporting an optimistic-lock failure.
The supporting mechanism is verified: suppress E11000 on the _id index when the filter carries optimistic-lock bindings, and report zero rows affected. Hibernate's Expectation.RowCount then converts the zero row count into the optimistic-lock failure itself, exactly as it does for SQL dialects whose merge matches nothing.
Deferred because the suppression must be conditional on the violated index being _id, otherwise a genuine unique violation elsewhere is reported as a lock failure and the application may retry it forever. The only signal identifying the violated index is the server error message text, and parsing it is not a sound correctness foundation on any layer; a driver-side accessor was considered and rejected for the same reason.
- related to
-
HIBERNATE-217 Support StatelessSession.upsert on unversioned entities
-
- In Code Review
-