Quote:
So if I understand you correctly, you're recommending I create two classes, PositionSkill and ApplicantSkill. Each class (table) is pretty much the same (with a generated skill_id), except that PositionSkill has a position_id column (Long) and ApplicantSkill has a applicant_id column (Long).
Yes. And each would have a position_id column that would not be a part of the Hibernate id mapping (because, as you know, that would require a composite-id mapping). From what little I know about your project this sounds right to me.
Quote:
There is not mapping in the *Skill objects to their parents, but there is a mapping from Position and Applicant to their respective child tables? I'm assuming that creates a foreign_key contraint in the child tables?
Right, you would have foreign key constraints with the child tables in the database but so long as each child record has a unique key of it's own you don't need to get into composite-id in Hibernate which will cut down the amount of code you have to write (and make things easier to work with). And if you wanted to you could make it bidirectional with little effort.
Quote:
The idea is to make it easy for the HR person *and* the applicant to enter skills. Maybe we could lookup the existing list of skill names for each table and present them to users, but we'd have to enter a new record when they added them to a position to set the position_id in the position/applicant_skill table.
That sounds like a good way to cut down on duplicate entries but you will need to use an x-ref I think to be able to reuse the skills on multiple positions.
You could conceiveably put all the skills in one table and make both groups of users pick from the same list but that might just complicate things also?
example mapping:
Code:
<class name="Position" ...>
...
<set name="positionSkills" table="position_skill" ...>
<key column="position_id">
<one-to-many class="PositionSkill"/>
</set>
<set name="applicantSkills table="applicant_skill" ...>
<key column="position_id">
<one-to-many class="ApplicantSkill"/>
</set>
...
</class>
<class name="PositionSkill" ...>
<id name="positionSkillID" column="skill_id" ...>
<generator .../>
</id>
...
</class>
Something to that effect I think, there are lots of little things to tweak and work out (such as reusing records and having a x-ref and then using many-to-many instead of one-to-many etc.) and I may have not been detailed enough to be totally correct for it to run first try.
There are some full fledged examples in chapter 16 of the 2.1 documentation.