-->
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: One-to-many without foreign key. Is this possible?
PostPosted: Fri Aug 08, 2008 11:55 am 
Newbie

Joined: Tue Sep 21, 2004 6:10 pm
Posts: 16
Location: Toronto, Canada
Hibernate version: 3.2.6

Mapping documents: Blueprint
<hibernate-mapping>
<class name="Blueprint" table="Blueprints">
<cache usage="nonstrict-read-write" />

<id name="id"
column="BlueprintId"
type="long"
unsaved-value="-1"
>
<generator class="native">
</generator>
</id>

<version
name="version"
column="Version"
type="java.lang.Integer"
unsaved-value="null"
/>

<property
name="created"
type="timestamp"
update="false"
insert="true"
column="Created"
/>

<set name="scores" access="field" inverse="true" cascade="none" where="OwnerType=37">
<key column="OwnerId"/>
<one-to-many class="Score"/>
</set>

</class>

</hibernate-mapping>

Mapping Document Score:
<hibernate-mapping>
<class name="com.bps.iproject.domain.score.Score" table="Score" >

<cache usage="nonstrict-read-write" />

<id name="id" column="ScoreId" type="long" access="field" unsaved-value="-1">
<generator class="native"/>
</id>

<component name="result" class="com.bps.iproject.domain.score.ScoreValue" access="field">

<property name="numericValue" type="double" update="true" insert="true" column="NumericValue"
access="field"/>

<property name="textValue" type="string" update="true" insert="true" column="TextValue"
access="field"/>

</component>

<component name="owner"
class="com.bps.iproject.domain.DomainObjectPointer" access="field">

<property name="objectId" type="long" update="true"
insert="true" column="OwnerId" not-null="true" />

<property name="objectType" type="int" update="true"
insert="true" column="OwnerType" not-null="true" />

</component>

<property name="scoreType" type="string" column="ScoreType" access="field" not-null="true"/>

</class>
</hibernate-mapping>

So here is the problem: I need to map the scores set in the Blueprint class but I can't afford to have a foreign key from the scores OwnerID column to the Blueprints table.
The reason for this is that other objects in the system will take scores. Scores have the owner which could be any other kind of object which is why there can not be a foreign key from the Score table to the Blueprint Table.
Has anyone deal with something like this before? Are we approaching this problem incorrectly?

Thanks in advance.

Erick.


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.