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.
|
|