|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Many to Many GORM join table issueI have a m-m relationship mapped like so:
class Product{ static hasMany = [categories:Category] ...other fields here } class Category{ static hasMany = [products:Product] static belongsTo = Product ....other fields here } This creates 3 tables (names not exact) Product Product_Categories Category The problem is that when I associate a product with a category by doing this: product.addToCateogries(Category.get(1)) //or something similar product.save() the Product_categories table gets the IDs in the wrong column. The Product id goes into the category_id column and vice versa. Any ideas? I am not sure what I am doing wrong here... Thanks, Steve |
|
|
Re: Many to Many GORM join table issueThis is intentional - see http://jira.codehaus.org/browse/GRAILS-828
You can re-reverse them using the mapping closure. Burt On Thursday 15 May 2008 1:50:24 pm Steve Mayzak wrote: > I have a m-m relationship mapped like so: > > class Product{ > static hasMany = [categories:Category] > ...other fields here > } > > class Category{ > static hasMany = [products:Product] > static belongsTo = Product > ....other fields here > } > > This creates 3 tables (names not exact) > Product > Product_Categories > Category > > The problem is that when I associate a product with a category by doing > this: > product.addToCateogries(Category.get(1)) //or something similar > product.save() > > the Product_categories table gets the IDs in the wrong column. The Product > id goes into the category_id column and vice versa. > > Any ideas? I am not sure what I am doing wrong here... > > Thanks, > Steve --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Many to Many GORM join table issueBurt,
Thanks for the quick reply. I should have checked JIRA first... Has this tripped you, or anyone else, up in working with the database with DBA's etc? On Thu, May 15, 2008 at 10:57 AM, Burt Beckwith <burt@...> wrote: This is intentional - see http://jira.codehaus.org/browse/GRAILS-828 |
|
|
Re: Many to Many GORM join table issueThat was my concern when I first mentioned this, that a non-Grails person like
a DBA would be confused. I haven't had any issues, but then we haven't hired a DBA yet :) Burt On Thursday 15 May 2008 2:00:52 pm Steve Mayzak wrote: > Burt, > > Thanks for the quick reply. I should have checked JIRA first... > Has this tripped you, or anyone else, up in working with the database with > DBA's etc? > > On Thu, May 15, 2008 at 10:57 AM, Burt Beckwith <burt@...> > > wrote: > > This is intentional - see http://jira.codehaus.org/browse/GRAILS-828 > > > > You can re-reverse them using the mapping closure. > > > > Burt > > > > On Thursday 15 May 2008 1:50:24 pm Steve Mayzak wrote: > > > I have a m-m relationship mapped like so: > > > > > > class Product{ > > > static hasMany = [categories:Category] > > > ...other fields here > > > } > > > > > > class Category{ > > > static hasMany = [products:Product] > > > static belongsTo = Product > > > ....other fields here > > > } > > > > > > This creates 3 tables (names not exact) > > > Product > > > Product_Categories > > > Category > > > > > > The problem is that when I associate a product with a category by doing > > > this: > > > product.addToCateogries(Category.get(1)) //or something similar > > > product.save() > > > > > > the Product_categories table gets the IDs in the wrong column. The > > > > Product > > > > > id goes into the category_id column and vice versa. > > > > > > Any ideas? I am not sure what I am doing wrong here... > > > > > > Thanks, > > > Steve > > > > --------------------------------------------------------------------- > > To unsubscribe from this list, please visit: > > > > http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Many to Many GORM join table issueThanks for your help Bert! I guess we'll see how it goes with a DBA!
Like you said though, we can re-reverse it if necessary. On Thu, May 15, 2008 at 11:07 AM, Burt Beckwith <burt@...> wrote: That was my concern when I first mentioned this, that a non-Grails person like |
| Free Forum Powered by Nabble | Forum Help |