Grails
  1. Grails
  2. GRAILS-6386

CLONE -Many-To-Many Mapping with Subclasses does not work

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.0.3
    • Fix Version/s: 1.3-RC1
    • Component/s: Persistence
    • Labels:
      None
    • Environment:
      Mac OS X Leopard, Grails 1.0.3
    • Testcase included:
      yes

      Description

      Using a many to many relationship with bi-directional navigation fails, if one of the related classes gets subtyped (i.e. subclassed).

      For an overview see:

      http://siprell.blogspot.com/2008/07/gorm-inheritance-relationships.html

      Otherwise I have attached my sources to the Issue. To reproduce run a grails clean and then a grails test-app.

        Activity

        Hide
        Corin Moss added a comment -

        I've cloned this issue highlight the aspect of this bug reported below.

        The previous fix (3273) works for most cases, but I've discovered a fringe case: it requires that the class with belongsTo defined has only one belongsTo definition - ie, the following will still produce the error:

        class Pentagon extends Shape{
        
        }
        
        class Shape { 
          static hasMany = [attributes:ShapeAttribute] 
        }
        
        class TwoDimensionalThing {
        
        }
        
        class ShapeAttribute{ 
          String name 
          String value 
          static hasMany = [shapes: Shape] 
          static belongsTo = [shape:Shape, twoDimensionalThing:TwoDimensionalThing] 
        }
        
        

        i.e. Grails will fail to start with the message:

        Error loading plugin manager: No owner defined between domain classes [class Shape] and [class ShapeAttribute] in a many-to-many relationship. Example: static belongsTo = Shape
        

        whereas if the belongsTo is only:

        static belongsTo = Shape
        

        It seems to work as expected.

        Show
        Corin Moss added a comment - I've cloned this issue highlight the aspect of this bug reported below. The previous fix (3273) works for most cases, but I've discovered a fringe case: it requires that the class with belongsTo defined has only one belongsTo definition - ie, the following will still produce the error: class Pentagon extends Shape{ } class Shape { static hasMany = [attributes:ShapeAttribute] } class TwoDimensionalThing { } class ShapeAttribute{ String name String value static hasMany = [shapes: Shape] static belongsTo = [shape:Shape, twoDimensionalThing:TwoDimensionalThing] } i.e. Grails will fail to start with the message: Error loading plugin manager: No owner defined between domain classes [class Shape] and [class ShapeAttribute] in a many-to-many relationship. Example: static belongsTo = Shape whereas if the belongsTo is only: static belongsTo = Shape It seems to work as expected.

          People

          • Assignee:
            Unassigned
            Reporter:
            Corin Moss
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development