Optimistic locking and updating only objects that are changed are two different things.
As long as an object is "connected" to the hibernate session changes are automatically detected and hibernate writes these changes back to database when the transaction is commited.
If you declare a column for versioning purposes hibernate increments this value each time it updates a database row. Say you have a column id which keeps your ID and version which keeps the version. Using optimistic locking does an update like this "..., version = ? where id = ? and version = ?". Because hibernate read the database row with a certain ID and Version an update to that row has to update exactly one row. So if the update statement returns 0, hibernate knows that the row is deleted or updated by another transaction.