Hi, I have classes mapped like this:
class Parent { @Id int parentId; @Version int version; @OneToMany(...) List<Child> children; } class Child { @Id int childId; ... // no relationship to parent, its uni-directional } The foreign key is on the CHILD table, but in JPA parlance the 'owner' of the relationship is the Parent, since it is uni-directional. It is kind of implied by this that this is a relationship by composition; the Child is part of the Parent and does not exist independently of it. We noticed that when a new Child is added to a Parent, the version stamp on the parent is bumped by one. From a database point of view this seems incorrect, since only the CHILD table is modified, and PARENT does not need to be touched. From a OO point of view, this seems correct, since the list on the Parent was updated, so Parent has changed. http://en.wikibooks.org/wiki/Java_Persistence/Locking#Cascaded_Locking Sheds some light on the issue: "Locking objects is different than locking rows in the database. An object can be more complex than a simple row; an object can span multiple tables, have inheritance, have relationships, and have dependent objects. So determining when an object has *changed* and needs to update its' version can be more difficult than determining when a row has changed." So my question is: In what circumstances would the Parent version be bumped by one? Does it happen on all relationships, or only to the side of a relationship considered to be the 'owner'. For example, If I put a @ManyToOne link back from Child to Parent, so that Child is now the 'owner' of the relationship, and holds the foreign key, it is kind of implied that this is a relationship by aggregation and the Child is independent. Would the Parent version still get bumped by one in this case? Is there an option in OpenJPA to turn off bumping of the parent version? Thanks for your help. Rupert