Hi,
First of all there is no table called ProgramCourseLanguage. In fact, its name is QuickSkillCourseLanguage. This table stores has references from 3 tables viz.,
1) QuickSkillProgramMaster
2) QuickSkillCourseMaster
3) LanguageMaster
All the ID columns of the above three tables are referred as foreign keys in QuickSkillCourseLanguage table.
I have already attached the hbm.xml files for all the above tables in my previous thread.
REQUIREMENTS
Case I:
One Program can have multiple courses and each of this course can belong to multiple language(s). By this I mean, that one ProgramId (say Program 'A') has two courses (say 'B', and 'C') and each of these courses are published in 2 languages English and Spanish.
So in this case I will have following entries in my respective table:
a) QuickSkillProgramMaster table :
One entry (for Program A)
b) QuickSkillCourseMaster table :
Two entries (for Course B and C with Program 'A' actign as a
Foreign key)
c) QuickSkillCourseLanguage table :
Four entries (2 languages(English and Spanish) each for two
Courses (B and C). In this case, the Courses B and C will act as a
Foreign key in QuickSkillCourseLanguage table and the value will be
stored in the QuickSkillsCourseId column. In this case, the
QuickSkillsProgramId column in QuickSkillCourseLanguage table will
have a null value.
Case II:
A Program can DIRECTLY belong to multiple languages. (No Courses)
By this I mean, that one ProgramId (say Program 'A') is DIRECTLY published in 2 languages English and Spanish. NO COURSES INVOLVED.
So in this case I will have following entries in my respective table:
a) QuickSkillProgramMaster table :
One entry (for Program A)
b) QuickSkillCourseLanguage table :
Two entries [2 languages(English and Spanish) each for
Program A]. In this case, the Program A will act as a Foreign key in QuickSkillCourseLanguage table and the value will be stored in the QuickSkillsProgramId column. The QuickSkillsCourseId column in QuickSkillCourseLanguage table will have null values in this case
Either a Program or a course must have languages. A language cannot be left blank.
The issue that I am facing
When I try to edit a Program Name (in case II) keeping the languages unchanged, and try to save I am getting an error "Violation of unique key constraint. Cannot insert duplicate key in the QuickSkillCourseLanguage table." The QuickSkillCourseLanguage has a unique key defined in the combination of "QuickSkillsProgramId" + "QuickSkillsCourseId" + "LanguageId".
I am trying to achieve this using Cascade.
I hope this information fully explains everything
Plese let me know, if you still have any issues pertaining to this context
_________________ Thanking You in advance
Kind Regards
Pratik Shah
|