Is it possible? I try to do it this way, but it doesn't work:
StatelessSession sess = getSessionFactory().openStatelessSession();
sess.beginTransaction();
MessageDetails md = (MessageDetails) sess.get(MessageDetails.class,1189469L);
md.setCc(null);
sess.update(md);
sess.getTransaction().commit();
sess.close();
cc is defined this way:
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "MessageEntryCc")
public Set<EmailAndName> getCc() {
return cc;
}
After running code, MessageEntryCc still contains entries with message_details_id = 1189469...
Please add CascadeType=DELETE_ORPHAN
as well in your mapping as:
@ManyToMany(fetch = FetchType.LAZY,
cascade={CascadeType.ALL, CascadeType.DELETE_ORPHAN})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.