unidirectional M2M does not delete the intersection rows

56 views
Skip to first unread message

Ilja

unread,
May 9, 2012, 7:10:25 AM5/9/12
to eb...@googlegroups.com
Hello!

(ebean.version: 2.7.5, h2: 1.2.128)

class Group {
...
    @ManyToMany(cascade = {CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.MERGE})
    private List<Application> applications;
...
}

Ebean.delete(groupsForRemoval)
cause
Referential integrity constraint violation: "FK_EXTENSION_TABLE_GROUP_TABL_02: PUBLIC.EXTENSION_TABLE_GROUP_TABLE FOREIGN KEY(GROUP_TABLE_ID) REFERENCES PUBLIC.GROUP_TABLE(ID)

According to http://www.avaje.org/bugdetail-221.html the intersection rows must be deleted.

To avoid this problem I use
for (Group group : groupsForRemoval) {
    Ebean.deleteManyToManyAssociations(group, "applications");
}
Ebean.delete(groupsForRemoval);

Is it bug?

Best regards,
Ilja.

Rob Bygrave

unread,
May 10, 2012, 8:58:58 AM5/10/12
to eb...@googlegroups.com
It sounds like a bug to me yes.
Reply all
Reply to author
Forward
0 new messages