You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The beforeDelete() method is able to remove the object being deleted from other associations in the database.
Actual Behaviour
An exception is thrown when the session is flushed:
Hibernate operation: could not execute statement; SQL [n/a]; Referential integrity constraint violation: "FKGHKKY8WMH379RPMFH92T807RY: PUBLIC.TEAM_MEMBERS FOREIGN KEY(PERSON_ID) REFERENCES PUBLIC.PERSON(ID) (1)"; SQL statement:
delete from person where id=? and version=? [23503-194]; nested exception is org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "FKGHKKY8WMH379RPMFH92T807RY: PUBLIC.TEAM_MEMBERS FOREIGN KEY(PERSON_ID) REFERENCES PUBLIC.PERSON(ID) (1)"; SQL statement:
delete from person where id=? and version=? [23503-194]
Notes
Following the advice from GORM Gotchas (Part 2) I understand that many-to-many relationships do not cascade deletions, so I need to manage them on my own. The domain's beforeDelete() method seemed like the perfect place to document this and other side-effects of deleting an instance.
If this is not possible I think there should be a section in the documentation that explains a recommended way of cleaning up associated join tables for many-to-many relationships. I think this situation is common enough to warrant it. I don't mind writing that section if it's confirmed that the sample project exhibits correct behavior.
Task List
Steps to Reproduce
beforeDelete()
method (utilizingwithNewSession
as outlined here: http://gorm.grails.org/6.0.x/hibernate/manual/#_the_beforedelete_event)Expected Behaviour
The
beforeDelete()
method is able to remove the object being deleted from other associations in the database.Actual Behaviour
An exception is thrown when the session is flushed:
Notes
Following the advice from GORM Gotchas (Part 2) I understand that many-to-many relationships do not cascade deletions, so I need to manage them on my own. The domain's
beforeDelete()
method seemed like the perfect place to document this and other side-effects of deleting an instance.If this is not possible I think there should be a section in the documentation that explains a recommended way of cleaning up associated join tables for many-to-many relationships. I think this situation is common enough to warrant it. I don't mind writing that section if it's confirmed that the sample project exhibits correct behavior.
Environment Information
openjdk version "1.8.0_162"
Example Application
automatic-collection-purge
branchThe text was updated successfully, but these errors were encountered: