When an attachment is saved, the metadata is saved before the content.
A transaction is opened, session.update() is called on the attachment metadata, then the attachment content is saved. When the content is saved, the latest version is added to the archive. When the latest version is added to the archive, the attachment version number and date on the attachment are changed. this alters the metadata and this altered metadata must be saved.
Hibernate does not actually send any UPDATE statements to the database until commit() is called and it saves the objects in whatever state they are in when commit is called. This is arguably a bug and unless someone has documentation on this behavior, it must be regarded as unreliable.