次のドメイン クラスでは、起動時にこのマッピング例外が発生します。
「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 [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'
}
これは私の別のドメインクラスで、複合キーも持っています
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']
}
}
この問題を解決するのに苦労しています。既存のスキーマのためにこれを機能させたいのですが、何が問題で、どのように修正するか教えてもらえますか?
知識を共有していただきありがとうございます。