Nested Select: passing

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Nested Select: passing

PierreR
Following the documentation I can easily pass a column value from one
select to another:

<select id=”selectBlog” resultMap="blogResult"
parameterType="java.util.Map">
        SELECT

        <if test="lang=='fr'">
           nameFR name
        </if>
        <if test="lang=='nl'">
           namenNL as name
        </if>
 FROM PERSON WHERE ID = #{id}
</select>

<resultMap id=”blogResult” type=”Blog”>
<association property="author" column="blog_author_id"
javaType="Author"
select=”selectAuthor”/>
</resultMap>

I am dealing with a case where not only I need a column value such as
"blog_author_id", I need parameters that were input



Nested Select for Association
select
The ID of another mapped statement that will load the complex type
required by this
property mapping. The values retrieved from columns specified in the
column
attribute will be passed to the target select statement as parameters.
A detailed
example follows this table.
Note: To deal with composite keys, you can specify multiple column
names to pass
to the nested select statement by using the syntax
column=”{prop1=col1,prop2=col2}”. This will cause prop1 and prop2 to
be set against
the parameter object for the target nested select statement.