-->
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: Mapping different subclasses to different properties
PostPosted: Fri Apr 01, 2011 5:35 am 
Newbie

Joined: Wed Jul 08, 2009 3:16 am
Posts: 2
Hi,

I have the following table model:

Expertise: ID
Phase: ID, EXPERTISE_ID, DISCRIMINATOR

Phase has 3 subclasses: FirstInstance, Appeal and Arbitration.

An Expertise has each time one of each phase, where FirstInstance is always required and the other two are optional.
So the idea is to have 3 properties in the expertise class:

Code:
public class Expertise {
  private FirstInstance firstInstance;
  private Appeal appeal;
  private Arbitration arbitration;
}


The mapping for the phases was straightforward:
Code:
<hibernate-mapping package="be.fgov.health.mediflow.schema.driver.model">
    <class name="Phase" table="PHASE">
        <id name="id" type="long" column="ID" >
            <generator class="native">
                <param name="sequence">SEQ_PHASE</param>
            </generator>
        </id>

        <discriminator column="DISCRIMINATOR" />

        <many-to-one name="expertise" column="EXPERTISE_ID" class="Expertise" not-null="true"/>
       
        <subclass name="FirstInstance" discriminator-value="FI">
        </subclass>
        <subclass name="Appeal" discriminator-value="AP">
        </subclass>
        <subclass name="Arbitration" discriminator-value="AR">
        </subclass>
    </class>
</hibernate-mapping>


But I don't seem to find a way to map the phases for expertise.
I'm pretty sure I need some kind of inverse mapping, but I don't need a collection. It's only a single item. Any ideas?
(I'm required to use Hibernate 3.2.6 without annotations)

Thanks in advance.


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.