The following Domain class gives this Mapping Exception on startup:
Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is 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])) must have same number of columns as the referenced primary key (testingcenter_examschedule [testingcenter_id,examschedule_id])
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'
}
and this is my another domain class which is also has a composite key
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']
}
}
I'm having a hard time to solve this problem, and I want to make this work because of my existing schema, can anyone tell me what's the problem and how to fix it?
Thanks for sharing your knowledge.