Please see my sqlMap file below, I have tried to use a
resultmap inside a resultmap, but it returns a list.
If entity is a concrete class, I can use the
dot.notation <result property="entity.id"
column="entityId">, for abstract class, I can include
the extra column "type" in the resultSet of the sql,
but how to tell the resultMap of orderResult to
instantiate a student or a insturctor instead of a
entity?

<sqlMap namespace="OrderEntry">

    <typeAlias alias="order"
type="com.test.model.Order"/>
    <typeAlias alias="entity"
type="com.test.model.Entity"/>
    <typeAlias alias="student"
type="com.test.model.Student"/>
    <typeAlias alias="instructor"
type="com.test.model.Instructor"/>


<resultMap id="orderResult" class="order">
        <result property="id" column="id"/>
        <result property="<"
resultMap="OrderEntry.entityResult" 
</resultMap>

<resultMap id="entityResult" class="entity">
        <result property="id" column="id"/>
        <discriminator column="type" javaType="integer" >
         <subMap value="1" resultMap="studentResult"/>
         <subMap value="2" resultMap="instructorResult"/>
        </discriminator>
</resultMap>
<resultMap id="studentResult" class="student"
extends="entityResult">
</resultMap>
<resultMap id="instructorResult" class="instructor"
extends="ownerResult">
</resultMap>


--- Gilles Bayon <[EMAIL PROTECTED]> wrote:

> You sould use the discriminator tag
> 
> On 11/9/05, Gilles Bayon <[EMAIL PROTECTED]>
> wrote:
> >
> > Yould use the discriminator tag
> >
> > On 11/9/05, Hongbo HE <[EMAIL PROTECTED]> wrote:
> > >
> > > I have a 1:1 relation of 2 tables. Multiple
> subClasses
> > > is mapped to one of them
> > >
> > > Order
> > > (id,
> > > entityId,
> > > ...
> > > )
> > >
> > > Entity
> > > (id,
> > > type,
> > > ...
> > > )
> > >
> > > type is the discriminator.
> > >
> > > Order {
> > > long id;
> > > Entity entity;
> > > }
> > >
> > > abstract Entity {
> > > long id;
> > > }
> > >
> > > Instructor extends Entity {
> > > }
> > >
> > > Student enxteds Entity {
> > > }
> > >
> > > I'd like to get an order together with its
> entity
> > > either Instructor or Student, I can't use the
> > > dot.notation.to.specify.the.properties, since
> > > it will try to instantiante an Entity class,
> which
> > > is not I wanted.
> > >
> > > Any help is greatly appreciated,
> > >
> > > Hongbo
> > >
> > >
> > >
> > > __________________________________
> > > Yahoo! FareChase: Search multiple travel sites
> in one click.
> > > http://farechase.yahoo.com
> > >
> >
> >
> 



        
                
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

Reply via email to