Hibernate Books

All times are UTC - 5 hours [ DST ]

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Hibernate: Mapping “Other” column in a collection cross refe
PostPosted: Mon Apr 16, 2012 2:58 pm 

Joined: Mon Oct 20, 2008 1:50 pm
Posts: 7
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">
        <generator class="increment"/>
    <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.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.