I 'm trying to save a Supplier object which has certain # of fields of type List. On saving, I get this error:
org.hibernate.HibernateException: reassociated object has dirty collection reference (or an array)
One of the helps on forum on net suggested to use cascade lock. So, I placed
@Cascade(org.hibernate.annotations.CascadeType.LOCK)
above all the getters of type List. But, this didn't help. Could anyone plz help me ?
Besides, most of the properties of the object have been provided with both java.persistence and hibernate annotations as shown below:
Code:
@ManyToMany(targetEntity = Color.class, cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
@JoinTable(name = "SUP_SUPPLIER_PERS_COLOR", uniqueConstraints = @UniqueConstraint(columnNames = { "SUPPLIER_ID",
"PERS_COLOR_ID" }), joinColumns = @JoinColumn(name = "SUPPLIER_ID"), inverseJoinColumns = @JoinColumn(name = "PERS_COLOR_ID"))
@Cascade(org.hibernate.annotations.CascadeType.ALL)
@OrderBy("description")
public List<Color> getColors() {
if (null == colors) {
colors = new ArrayList<Color>();
}
return colors;
}
Do I need to add both annotations ?
[/b]