Hello,
I'm working with hibernate and I've got the following exception :
Code:
org.springframework.orm.hibernate4.HibernateSystemException: Found shared references to a collection
Indeed, I'm trying to put in a collection (Set<LocString> label) of my entity (type 'Attribut') the same collection of another entity (same type of entity). I really want datas to be the same (same ids, same everything). I would like ton point on same rows in database and same datas in cache. But, I don't know how to do to not have this exception. When I try to save my Entity I always have the previous exception. How can I do to have my both entities pointing on the same collection of LocString (see next code)
Here are my entities
Code:
@Entity
@Table(name="T_ATTRIBUT")
public class Attribut implements Serializable{
private static final long serialVersionUID = -2364367529355309198L;
private long id;
private Set<LocString> label = new HashSet<LocString>(0);
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="ID")
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL)
public Set<LocString> getLabel() {
return label;
}
public void setLabel(Set<LocString> label) {
this.label = label;
}
...
and about the locString entity :
Code:
public class LocString implements Serializable {
private static final long serialVersionUID = -3384318618274464353L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="ID")
private long id;
@Column(name="LOCALE")
private String locale;
@Column(name="VALUE")
private String value;
...
Thank you very much for your help
Clement