以下 Domain 类在启动时提供此映射异常:
创建名为“sessionFactory”的 bean 时出错:调用 init 方法失败;嵌套 异常是 org.hibernate.MappingException:Foreignkey (FKA9FB5C607D60EAE9:person_examschedule [testingcenter_examschedule_id dummy_table,testing_center_exam_schedule_testing_center_id,testing_center_exam_schedule_exam_schedule_id]) 必须具有与引用的主键相同的列数 (testingcenter_examschedule_test])
class TestingCenterExamSchedule implements Serializable{
Long testingCenterId
ExamSchedule examSchedule
TestingCenter testingCenter
int bufferedSlots
static transients = ['testingCenter']
static constraints = {
examSchedule nullable: false
testingCenter nullable: false
testingCenterId nullable: false
bufferedSlots nullable:false
}
static mapping = {
table 'testingcenter_examschedule'
version false
id composite: ['testingCenterId','examSchedule']
testingCenterId column: 'testingcenter_id'
examSchedule column: 'examschedule_id'
bufferedSlots column: 'buffered_slots'
}
这是我的另一个域类,它也有一个复合键
class RegistrantTestingCenterExamSchedule implements Serializable {
Registrant registrant
TestingCenterExamSchedule testingCenterExamSchedule
static constraints = {
registrant nullable: false
testingCenterExamSchedule nullable: false
}
static mapping = {
table 'person_examschedule'
version: false
id composite: ['registrant', 'testingCenterExamSchedule']
columns {
registrant column: 'person_id'
testingCenterExamSchedule column: ['testingcenter_examschedule_id', 'dummy_table']
}
}
我很难解决这个问题,由于我现有的架构,我想完成这项工作,谁能告诉我问题是什么以及如何解决它?
感谢您分享您的知识。