I think its better if I synchronize the 2 call rather relying on Hibernate throwing any exception.
No. Synchronizing database access should not be required; it kind of defeats the purpose of using a data store that happily allows concurrent access when you then restrict the access to one user at a time. Hibernate's optimistic locking support (as I said before) works. And its worked for some time.
Be aware that directly updating the database via SQL may not have the effect you want. Remember the Session acts as a short-lived first level cache.
Also while debugging my application I changed the version_id value (using direct update sql) after BatchInfo is fetched and when the update happens the table record never gets updated which is correct as the version_id in database for this record is now different but application is not throwing any exceptions.
This sounds very suspicious, and makes me think again that the exception is getting "lost" rather than not being thrown. Turn on debugging for Hibernate. Get it to log the SQL it is issuing too. See what's going on under the hood.
[ June 02, 2006: Message edited by: Paul Sturrock ]