Hibernate version: 3.2
Name and version of the database you are using: MySQL 5
Hi,
I'd like to force an update on the version of an entity, even if no changes occurred. It seems like the LockMode FORCE does just this, but it also locks the entity pessimisticly, which I really don't want to.
Is there a way to force a version update without a pessimistic lock of the entitiy?
Here is what I need this for (if you are interested):
For performance reasons, I need to store the cardinality of a referenced collection in my entity. For this I update the reference count via a scheduled job (the value does not have to be up-to-date). This job compares the version timestamp of the referenced collection elements and the entity and updates the reference count, if an entry in the collection is newer than the entitiy. However, if the reference count is already correct on my entity, Hibernate recognizes that the entity is not dirty and does not update it, so the version does not change. The result is, that the next job picks up the entity again, and so on (if no collection element is added).
I know this is propably not the intended usage for the version, but it would be the most efficient way I can think of.
Any hints are greatly appreciated!
Kai
|