| Code [0] fails with [1]. I am just trying to pesimistically lock an entity in the same transaction where I created it. Cause is that 1) Entity has SEQUENCE id generator, Hibernate doesn't flush before the find() nor before the lock(). 2) With PESSIMISTIC_WRITE Hibernate has to issue SELECT FOR UPDATE. Because entity is not inserted at the time of the SELECT FOR UPDATE, the find/lock fails.... Currently I workaround this by flushing before acquiring the pessimistic lock. [0]
[1]
|