Hi
I have an object call user which has a list of attribute as its property:
@Entity(name = "User")
@Table(name = "tz_user")
Code:
public class User{
private Long userId;
private Set<Attribute> attributes;
@ManyToMany(fetch = FetchType.LAZY, cascade = {javax.persistence.CascadeType.DETACH})
@Cascade({CascadeType.DELETE_ORPHAN, CascadeType.SAVE_UPDATE})
@JoinTable(name = "tz_userattributes",
joinColumns = @JoinColumn(name = "userId"),
inverseJoinColumns = @JoinColumn(name = "attributeId"))
public Set<Attribute> getAttributes() {
return attributes;
}
}
the attribute object:
Code:
@Entity(name = "Attribute")
@Table(name = "tz_attribute")
public class Attribute extends {
private Long attributeId;
private String value;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getAttributeId() {
return attributeId;
}
public void setAttributeId(Long attributeId) {
this.attributeId = attributeId;
}
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
Whenever I delete with session.delete an item from the list of attributes....only the row in the "tz_userattributes"
joined table is removed.How can I remove the attribute from the "tz_attribute" table?
Thanks
Lilachha