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 event
s, 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
Post a Comment