« Return to Thread: Many to Many GORM join table issue

Re: Many to Many GORM join table issue

by burtbeckwith :: Rate this Message:

Reply to Author | View in Thread

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


 « Return to Thread: Many to Many GORM join table issue

LightInTheBox - Buy quality products at wholesale price