grails - Unidirectional Many To One mapping with cascade -


is possible map following gorm?

i want rid off associated events when delete person.

person object should not have link events.( want avoid using hasmany on person domain)

class person {     string username }  class event {     string description     static belongsto = [person:person] } 

i'm getting 'referential integrity constraint violation' when doing person.delete() because events not removed before deleting person.

i don't think possible without using hasmany (speaking of which, why want avoid anyway?)

this question states:

hibernate cascades along defined associations. if knows nothing bs, nothing affect bs.

use static hasmany , bam, problem fixed.

edit:

the way think achieve using beforedelete on person class delete associated events, i.e.

class person {     def beforedelete() {         def events = event.findallbyperson(this)         (e in events) {             e.delete()         }     } } 

see the documentation on events , auto timestamping more info on that.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -