Hi
I met a problem when I use Hibernate Annotation 3.2.1 GA.
A entity A is associated with many entity B. A and B are mapped by a parent-child relationship by the annotation.
I use the optimistic versioning or locking. But I donot want the entity A's version to be increased when an instance of B is added to or removed from the association.
How could I do it?
Thanks for your help.
The following is the annotation. I tried optimisticLock=OptimisticLockType.NONE, but it does not solve my issue.
Code:
@Entity
@org.hibernate.annotations.Entity( dynamicInsert=true, dynamicUpdate=true,
optimisticLock=OptimisticLockType.NONE )
public class Conference implements java.io.Serializable {
@Id
private Long id;
@Version
@Column(name = "OBJ_VERSION")
private int version;
private long confId ;
@OneToMany(mappedBy="conference", cascade={CascadeType.ALL}, fetch = FetchType.EAGER )
@Cascade({org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
@org.hibernate.annotations.MapKey(columns=@Column(name="legId"))
private Map<Long, CallLeg> calls = new HashMap<Long, CallLeg>();
......
}
@Entity
@org.hibernate.annotations.Entity( dynamicInsert=true, dynamicUpdate=true,
optimisticLock=OptimisticLockType.VERSION )
public class CallLeg implements java.io.Serializable {
@Id
private Long id;
@Version
@Column(name = "OBJ_VERSION")
private int version;
private Long legId ;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="CONF_FK_ID")
@org.hibernate.annotations.ForeignKey(name = "TO_CONF_FK")
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
private Conference conference ;
......
}