views:

260

answers:

0

I am getting this exception: org.hibernate.MappingException: collection foreign key mapping has wrong number of columns: Room.cellsOrig type: component[locationX,locationY]

class Room implements Serializable {
    Integer locationX;
    Integer locationY;
    List cellsOrig = []
    List cells = []

    static hasMany = [cellsOrig: Cell, cells: Cell]
    static mapping = { id composite['locationX', 'locationY']
        cells joinTable:'room_cells'
        cellsOrig joinTable:'room_cells_orig'
    }
    static constrants = { locationX(nullable: false) locationY(nullable: false)   
        cells(nullable: false) cellsOrig(nullable: false) 
    }
}

I think I am doing the joinTable wrong, but without the joinTables any access to a Room instance's cell or cellOrig properties would cause org.hibernate.HibernateException: null index column for collection: Room.cells.

Any suggestions for how to do the joinTable in such a way that it can handle the composite id?