...
Panel | ||
---|---|---|
IMPORTANT: Load vs GetThere is a difference between Hibernate's load and get methods for retrieving data that is important in checking for concurrent updates:
The reason this is important for concurrent update checking is that a proxy object generated by a load will not contain the version information we need. Our scheme depends on the version being loaded at the start of a with two sessions working with an object with the same identifier. Initial version for object in DB is 10.
We actually want session 1's commit to fail with an optimistic lock exception, but it will succeed here. Using "get" instead of "load" works around the problem, because get will immediately issue a select, and the version numbers will be loaded at the correct times for the optimistic lock checking. We actually want session 1's commit to fail with an optimistic lock exception, but it will succeed here. Using "get" instead of "load" works around the problem, because get will immediately issue a select, and the version numbers will be loaded at the correct times for the optimistic lock checking. |
...