Yes, I am forced to use this table schema.
I am using Hibernate as the JPA2-Provider.
Now for
SCHOOL ACTIVITIES, I do
NOT have a specified
GETTER/SETTER for the
StudentId or the
SchoolOfficialsId in the
EJB 3.0 Entity of
SchoolActivities. Instead I have the
GETTER/SETTER for
Student and
SchoolOfficials. I
DO have the
GETTER/SETTER for the
StudentId on
Student and the
GETTER/SETTER of the
SchoolOfficialsId on the
SchoolOfficials EJB 3.0 Entities though. Overall I think this setup is correct due to the
STUDENT<->SCHOOL ACTIVITIES<->SCHOOL OFFICIALS relationship.
I am using
List<SchoolActivities> schoolActivitiesList as my
GETTERS/SETTERS between
STUDENT<->SCHOOLACTIVITIES and
SCHOOLOFFICIALS<->SCHOOLACTIVITIES.
For the Java-code logic I used to add a
single-entry to
all 3 correlated-tables, I did a
.set on
ALL the relevant field-values for all 3 tables with
.set encapsulation. In addition, for the
LIST fields (which correlates to the
STUDENT<->SCHOOLACTIVITIES and
SCHOOLOFFICIALS<->SCHOOLACTIVITIES relationships), I first .set all the fields in a
SchoolActivities entity instance and then I encapsulated that specific
SchoolActivities entity by doing something like this:
For Student entity
For SchoolOfficials entity