saveOrUpdate « Version « JPA Q&A

1. Hibernate saveOrUpdate - Cascade - Automatic Versioning

My question is How can I get new version number of the object after calling saveOrUpdate method? Please check following scenario

class ServiceInfo{
   int serviceId;
   Set<InfoItem> infos;   

2. saveOrUpdate() reving version on unchanged objects!

I have the following issue where Foo is using hibernate's automatic versioning: Foo foo = new Foo(); // Inserts new Foo object with version 0 as expected foo = session1.saveOrUpdate(foo); // The following line revs the version of foo to 1 and Session.isDirty() // will return true even though *no* modifications have been made // to foo since the first save. ...

3. saveOrUpdate - Cascade - Automatic Versioning

class ServiceInfo{ int serviceId; Set infos; int version; } class InfoItem{ int serviceId some Properties... } Mapping file for ServiceInfo ...