ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Thompson" <artho...@gmail.com>
Subject How do I apply individual properties from a resultMap to another resultMap
Date Wed, 14 Mar 2007 16:35:05 GMT
I've run into a situation where i want to use two separate queries to build
one domain object.  The reason being that I need to use a stored procedure
for several attributes and standard SQL for the rest.  Unfortunately I can't
fix the stored proc to do everything I need, nor can I bypass that proc for
business reasons.

For example the below works, but doesn't do exactly what I want:

<resultMap id="FinalObject" class="com.domain.FinalObject">
    <result property="propertyA" column="A" />
    <result property="propertyB" column="B" />
    <result property="propertyC" select="execSQL"/>
</resultMap>

<procedure id="execStoredProc" resultMap="FinalObject"    >
    {call someProc(#value#) }
</procedure>

<resultMap id="sqlRS" class="java.util.Date">
   <result property="propertyC" column="columnC"/>
</resultMap>

<select id="execSQL" resultMap="sqlRS">
   select C from table where something=#value#
</select>

What I would really like is to modify the above such that sqlRS returns a
map.  and I can insert propertyC directly into FinalObject.  The below has
broken syntax - but illustrates logically what I would like.

Essentially:
<resultMap id="FinalObject" class="com.domain.FinalObject">
    <result property="propertyA" column="A" />
    <result property="propertyB" column="B" />
    <result property="propertyC" select="execSQL.propertyC"/> <!-- insert
one property from sqlRS into FinalObject-->
    <result property="propertyD" select="execSQL.propertyD"/> <!-- insert
another property from sqlRS into FinalObject-->
</resultMap>

<procedure id="execStoredProc" resultMap="FinalObject"    >
    {call someProc(#value#) }
</procedure>

<resultMap id="sqlRS">
   <result property="propertyC" column="columnC"/>
<result property="propertyD" column="columnD"/>
</resultMap>

<select id="execSQL" resultMap="sqlRS">
   select C, D from table where something=#value#
</select>

Is there a working syntax to accomplish logically what I'm trying to do
above?

-- 
Andrew R. Thompson
Currently in D.C. Consulting

Mime
View raw message