2

この例外が発生しています: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) 
    }
}

私は joinTable を間違って実行していると思いますが、joinTables がないと Room インスタンスの cell または cellOrig プロパティにアクセスするとorg.hibernate.HibernateException: null index column for collection: Room.cells.

複合 ID を処理できるように joinTable を実行する方法について何か提案はありますか?

4

1 に答える 1

0

クラスから1対多を作成したい場合。クラスが追加するCellsクラスでは、それを処理するRoomに属します....

  • ハルジット
于 2011-03-18T01:30:24.337 に答える