hibernate versioning parent entity

Posted by Priit on Stack Overflow See other posts from Stack Overflow or by Priit
Published on 2010-05-24T07:36:51Z Indexed on 2010/05/24 7:41 UTC
Read the original article Hit count: 259

Filed under:
|
|

Consider two entities Parent and Child.

  • Child is part of Parent's transient collection
  • Child has a ManyToOne mapping to parent with FetchType.LAZY

Both are displayed on the same form to a user. When user saves the data we first update Parent instance and then Child collection (both using merge).

Now comes the tricky part. When user modifies only Child property on the form then hibernate dirty checking does not update Parent instance and thus does not increase optimistic locking version number for that entity.

I would like to see situation where only Parent is versioned and every time I call merge for Parent then version is always updated even if actual update is not executed in db.

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate