My object model contains 2 objects of interest, a RuleGroup and a Rule
My RuleGroup object contains a Set of Rules.
Therefore, I have a cross reference table called RULE_GRP_MEMBER that maps between the RULE_GRP table and the RULE table to specify which Rules belong to a RuleGroup.
My RuleGroup mapping file is as follows, and this works fine with no problems.
<class name="a.b.c.d.RuleGroup" table="RULE_GRP">
<id name="ruleGroupID" column="RULE_GRP_ID">
<set name="rules" lazy="true" cascade="save-update" table="RULE_GRP_MEMBER">
<key column="RULE_GRP_ID" not-null="false"/>
<!-- Unique set to true makes this a one to many relationship -->
<many-to-many unique="true" column="RULE_ID" class="a.b.c.d.Rule"/>
My Rule mapping file does not contain any references to a RuleGroup object.
The problem is that we are now introducing a new non-null field RULE_SEQ onto the RULE_GRP_MEMBER table. So, when a new Rule is added to a RuleGroup, a new row will be added to the RULE_GRP_MEMBER table.
How do I go about mapping this RULE_SEQ field to my objects? Ideally I'd like to map it to my Rule object, but I'm not sure what Hibernate concept I should even use.