The correct way is to ensure that the Id and the version of the stored entity was never changed during it's roundtrip to other parts of the application.
Then take that detached storedEntity, and call merge on it:
YourEntity attachedEntity = entityManager.merge(storedEntity);
You can make further changes to the entity after attachment by using the attached entity reference, not the original storedEntity detached copy.
In general the version field should not be modified by the application, Hibernate will handle this. At most this field can be copied around between entities and DTOs.