I know Hibernate's optimistic locking will update the version in the parent when a child is updated. But, I have an issue where a collection in a child is being updated (I see the sql), but I don't see the version field being updated in the parent. Should I expect this as default behavior or am I missing an annotation setting on the child/child collection?
Thanks,
Rich
Here in a nutshell, is some example code:
Parent.java
@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
@Inheritance(strategy=InheritanceType.JOINED)
public Parent {
@Column(name="ID")
private Long id;
@Version
@Column(name="MODIFIED_DATE")
private Timestamp modifiedDate;
}
Child.java
@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
@PrimaryKeyJoinColumn(name="ID")
public Child extends Parent {
@BatchSize(size=100)
@OneToMany(mappedBy="owner", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
private List<ChildAttribute> attributes
}
ChildAttribute.java
@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
public ChildAttribute {
@Column(name="ID")
private Long id;
@ManyToOne
@JoinColumn(name="CHILD_ID")
private Child owner;
@Column(name="AMOUNT")
private double amount;
}
|