Grails 使用复合id时多个hasMany与同一域类的关系问题
我遇到此异常:Grails 使用复合id时多个hasMany与同一域类的关系问题,grails,groovy,gorm,Grails,Groovy,Gorm,我遇到此异常:org.hibernate.MappingException:集合外键映射的列数错误:Room.cellsOrig类型:组件[locationX,locationY] class Room implements Serializable { Integer locationX; Integer locationY; List cellsOrig = [] List cells = [] static hasMany = [cellsOrig
org.hibernate.MappingException:集合外键映射的列数错误:Room.cellsOrig类型:组件[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是错误的,但是如果没有joinTable,对文件室实例的单元格或CellRig属性的任何访问都会导致org.hibernate.hibernate异常:集合的索引列为null:Room.cells
如果要从类中创建一对多,有没有关于如何处理joinTable以使其能够处理复合id的建议?。在类添加的Cells类中,该类属于将处理它的房间
- 哈吉特
- 哈吉特