Code:
@Entity
@Table(name="Request")
public class Request implements Serializable {
private Long id;
private List<EmailValue> emailValues;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="request_id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToMany(fetch= FetchType.EAGER)
@JoinTable(name = "RequestEmailValue",
joinColumns = {@JoinColumn(name="request_id")},
inverseJoinColumns = {@JoinColumn(name="emailvalue_id")}
)
@Cascade({ org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
public List<EmailValue> getEmailValues() {
return emailValues;
}
public void setEmailValues(List<EmailValue> emailValues) {
this.emailValues = emailValues;
}
Code:
@Entity
@Table(name = "EmailValue")
public class EmailValue implements Serializable{
private Long id;
private String value;
public EmailValue() {
}
public EmailValue(String value) {
this.value = value;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "emailvalue_id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name = "value", nullable = false)
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
Nobody find the solution for this issue , i m in the same case.
I can delete a element in my collection WORKS
Code:
Request req = getSession().get(Request.class,new Long(id));
req.getEmailValues.remove(0);
getSession().update(req);
but if i CANT delete ALL the collection
Code:
Request req = getSession().get(Request.class,new Long(id));
req.setEmailValues(new ArrayList());
getSession().update(req);
i try to put a hashset the same behaviour.
thanks