1. When automatic versioning is used, hibernate generates the following sql:
update products set version=?, name=?, description=?, unitCost=?, pubTime=? where id=? and version=?
Note that using such sql, you don't need to select the version from database to compare with current version.
2. Other ways to resolve LazyInitializationException, except Open Session in View.
3. Note that for the Transaction in jta, you can register a Synchronization, though this you can be informed before or aftter transaction commit, is Hibernate use this way to flush? (Transaction manager manage Transaction by begin / suspend / getTransaction / setTransactionTimeout, its other methods just delegate to Transaction).