Hello!
How can one do a versionCheck without anything else, without using an entities getVersion() method? Is there any mean given by hibernate session?
I just want to check if my Object has the same version as the object
in the database.
Ok, if the object is in the session already, I can do it with the session´s get method.
get(Class clazz, Serializable id, LockMode lockMode)
But my problem is, I am not sure that this is the case.
The other option in my case would be to use session´s merge-method
merge(Object object)
that also does a version check. If it detects different versions in database and in object it throws an StaleObjectStateException, otherwise it will update the entry in the database. The problem with this solution is, that in my special case I want to do some more versionschecks, before deciding wether the database-entry should be updated or not.
I´m curious about hearing some suggestions and thank anyone making his brain working for me in advance.
Best regards,
Jörg
|