java - JPA composite foreign keys -
i have relationship cannot quite right in jpa. implementation hibernate.
i have these basic entities:
- volunteer (personal details)
- area (information work area)
- session (time slot - start & end time)
there's many-to-many relationship between volunteer & session, volunteer_session
, indicating volunteers willing work when.
there's many-to-many relationship between volunteer & area, volunteer_area
, indicating volunteers willing work in areas.
there's many-to-many relationship between area & session, area_session
additional column indicating how many volunteers needed in area during session.
so far, have relationships set correctly in jpa.
the next stage tricky - assignments.
volunteers may assigned area willing work in, during session willing work.
the table structure this:
assignment ---------- volunteer_id session_id area_id
where volunteer_id
, session_id
comprise primary key, , foreign key volunteer_session
table. also, volunteer_id
, area_id
should composite foreign key volunteer_area
table.
i post code here, it's long question , point want add assignment, it's ok. post if requested.
Comments
Post a Comment