grails - GORM 1-to-many relationship -- 3 tables created rather than 2 -


all

my problem i'm creating 1-to-many relationship in gorm , expect 2 database tables created backing objects. 3 created makes sql queries overly complex.

i've created close variant on 1-to-many in gorm documentation:

class status {     list errormessage     static hasmany = [errormessage:errormessage] } 

and error message class:

class errormessage {     string message     static belongsto = status } 

i expected create 2 database tables:

 create table status {    id number(19,0),    version number(19,0),    //other fields }  create table error_message {    id number(19,0),    version number(19,0),    status_id number(19,0),    message varchar(255)    //other fields } 

but wants third table,

  create table status_text {     status_text_id number(19,0),     text_idx number(19,0),      text_id number(19,0) }  

adding status errormessage (a hack don't want errormessage have reference status) class removes third table keeps second foreign key resulting in text child object having 2 foreign key fields.

what want simple - set of objects attached parent deleted when - thoughts i'm doing wrong?

thanks

i don't think can satisfy both requirements, i.e. have cascading deletes , no join table. need belongsto cascading deletes , makes relationship bidirectional. remove join table, name belongsto map syntax:

class errormessage {    string message    static belongsto = [status: status] } 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -