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.  [ 2 posts ] 
Author Message
 Post subject: Many-to-one relationship for an inherited class
PostPosted: Wed Sep 08, 2010 6:08 am 
Newbie

Joined: Fri Jul 09, 2010 4:52 am
Posts: 4
I have a general table with the structure

Code:
code_fldname     pk
code_value       pk
code_cmmt


I have mapped this through a mapping of:

Code:
<class name="GeneralCode" table="code_mstr">
  <composite-id name="key">
    <key-property name="key" column="code_fldName" type="string"/>
    <key-property name="value" column="code_value" type="string"/>
  </composite-id>
  <discriminator column="code_fldName" type="string" insert="false"/>
  <subclass name="Segment" discriminator-value="jrg_segment">
    <property name="name" type="string" column="code_cmmt"/>
  </subclass>
</class>


Now I wish to have "Segment" mapped as a many-to-one relationship on another entity where the discriminator column is not stored in the given table, i.e.

Code:
<many-to-one name="segment" class="com.johnsands.lineplan.Segment"
             lazy="false" insert="false" update="false">
  <!-- I'm not sure what to put here for the first column in the composite id. -->

  <!-- jrg_segment is the column within the given table I'm trying to map from (the second key in the composite-id). -->
  <column name="jrg_segment"/>
</many-to-one>


Top
 Profile  
 
 Post subject: Re: Many-to-one relationship for an inherited class
PostPosted: Wed Sep 08, 2010 6:56 am 
Newbie

Joined: Fri Jul 09, 2010 4:52 am
Posts: 4
I've managed to solve this using the "formula" tag.

Code:
<many-to-one name="segment" class="Segment"
             lazy="false" insert="false" update="false">
  <formula>'jrg_segment'</formula>
  <column name="jrg_segment"/>
</many-to-one>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.