These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Help mapping two objects that can each 'have' a third
PostPosted: Tue May 24, 2005 4:03 pm 
Beginner
Beginner

Joined: Wed Feb 23, 2005 11:29 am
Posts: 26
We're using Hibernate 2.1.7c with Firebird 1.5.2.

We have two objects, Solution and Service, each of which has a Map of ConfigSetting.

Initially we set it up such that both Solution and Service have a Map like this:

Quote:
<map name="configSettings"
table="CONFIGESETTING"
lazy="false"
inverse="false"
cascade="save-update">

<key column="service_id"/>
<index column="NAME" type="java.lang.String"/>
<one-to-many class="com.lexmark.workflow.framework.domain.configsetting.ConfigSettingImpl"/>
</map>


This resulted in two foreign key constraints being created, one from ConfigSetting to the ID column of Service, and another from ConfigSetting to the ID column of Solution. We got constraint violations because both foreign keys are never set - the ConfigSetting either goes with a Solution, or with a Service, so one of the foreign keys is always null.

I've been playing around with this and saw something about making the map one-to-many with inverse="true". This may have helped, since now the ConfigSetting just contains two columns, one for the id of the Service and another for the id of the Solution. But our testcases are failing and I'm not sure when I look in the database that the IDs are matching up.

I thought I would take a step back and ask someone how THEY would set this up. A good example of a similar set of objects would be very helpful.

-Jeff


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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.