ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric T. Blue" <ericblu...@gmail.com>
Subject Referencing a select statement or resultmap in another config file
Date Wed, 11 May 2005 23:14:23 GMT
Hi,

I have a number of objects/tables that require mapping, and in many 
instances there are 1-many relationships.  In order to minimize 
duplication in the config files, I would like to be able to reference a 
select statement in another namespace/config file.  For example:

// File 1

<sqlMap namespace="Object1">

    <resultMap id="object1Result" class="com.ericblue.domain.Object1">
        <result property="id" column="id"/>
        <result property="name" column="name"/>         
        <result property="someList" column="id" 
select="Object2.getSomeListByObject1"/>         
    </resultMap>

</sqlMap>

// File 2

<sqlMap namespace="Object2">

    <resultMap id="object2Result" class="com.ericblue.domain.Object2">
        <result property="id" column="id"/>
        <result property="name" column="name"/> 
    </resultMap>

    <select id="getSomeListByObject1" resultMap="object2Result">
       select * from some_table where id = #id#
     </select>

</sqlMap>

Any help is appreciated!




Mime
View raw message