我收到此异常: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的任何建议吗?
答案 0 :(得分:0)
如果您想从班级中创建一对多。在类类添加的Cells类中属于可以处理它的房间....