Problem domain: A Course has multiple Sections with Students.
OO Model: Students is a m:m with Section that requires an Association class (SectionStudent) that has additional value attributes like beg / end dates and calculated attributes like points earned / points possible.
Database Model (hsql):
CREATE TABLE PERSON(PERSONID BIGINT NOT NULL IDENTITY PRIMARY KEY,SUBCLASS VARCHAR(255) NOT NULL,UPDATECOUNT INTEGER NOT NULL,FNAME VARCHAR(25),PNAME VARCHAR(25),COMMENT VARCHAR(50),MNAME VARCHAR(25),LNAME VARCHAR(25),GENDER CHAR(1),SUFFIX VARCHAR(10),STUDNUM VARCHAR(25),STATUS SHORT)
CREATE TABLE SECTION(SECTIONID BIGINT NOT NULL IDENTITY PRIMARY KEY,UPDATECOUNT INTEGER NOT NULL,DESCRIPTION VARCHAR(50),PERIOD VARCHAR(50),MEETS VARCHAR(50),COMMENT VARCHAR(50),COURSE_UID BIGINT NOT NULL, ORDER INTEGER)
CREATE TABLE SECTION_STUDENT(SECTION_UID BIGINT NOT NULL,PERSON_UID BIGINT NOT NULL,BEGDATE DATE,ENDDATE DATE,CONSTRAINT SYS_PK_SECTION_STUDENT PRIMARY KEY(PERSON_UID,SECTION_UID),CONSTRAINT FK2D6F2E1224877F6 FOREIGN KEY(SECTION_UID) REFERENCES SECTION(SECTIONID),CONSTRAINT FK2D6F2E12878DC66 FOREIGN KEY(PERSON_UID) REFERENCES PERSON(PERSONID))
I am using Middlegen as a starting point for the mapping files and expect to generate the mapping files using Xdoclet tags in the .java files. When Middlegen creates the mapping for SectionStudent, it creates a composite id for SectionId, PersonId which makes sense. It also creates a new class SectionStudentPK to represent that value. Is this strictly necessary? It seems to me that the class is overhead that could be eliminated with a little extra code on the association class SectionStudent. But I am very new to Hibernate and want to make sure I am not missing a subtle (or obvious) reason for the additional class.
I appreciate your time and input!