When you detach a persistent entity just to transfer it to the web layer, as an example create DTO to transfer objects to the web layer. in that case we will transform Entity objects into the DTO objects using getters and setters.
If you need to maintain the concurrency control with Optimistic locking, you have to maintain the version number in your application (it's different from manually setting the version number). Otherwise there is no way we can instruct hibernate what was the old version of the loaded record. In hibernate documentation it says "Keep the disconnected Session close to the persistence layer. Use an EJB stateful session bean to hold the Session in a three-tier environment. Do not transfer it to the web layer, or even serialize it to a separate tier, to store it in the HttpSession. ", But all the environments do not have EJB stateful session beans in business layer. In that case we have to maintain the version number.
As long as you can maintain the version, you do not need to manually check the version in the program, it is efficient if you let hibernate to do that, because you cannot predict the depth of your object hierarchy.
So what you can do is you have to set the version again to the persistent entity if you use detached objects in the web layer, Then hibernate will take care of the Cocurrency Control.