ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nguyen Trong Hoan" <hoannt8...@vips.com.vn>
Subject Complex properties and substitution strings parameter problem (updated)
Date Tue, 23 Jan 2007 01:15:06 GMT
In my previous mail, I had a few mistake. I have updated it and resend you 
my problem as the following:

I'm developing a web app with ibatis (2.2) and have got a problem with 
complex properties and passing substitution strings parameter for sql query 
of properties.

For example:

<sqlMap namespace="user">
    <resultMap id="User" class="bean.User">
        <result property="id" column="id"  />
        <result property="name" column="name" />
        <result property="address" column="id" select="getAddress"/>

    <select id="getUser" parameterClass="map"  resultMap="User">
        SELECT id,name FROM $schema$.tbl_user WHERE id = #value#

    <select id="getAddress" parameterClass="int" resultClass="string">
        SELECT address FROM $schema$.tbl_address WHERE id = #value#

Here, bean.User class is declared as the following:
public class User {
    private String schema;
    private int id;
    private String name;
So, in my program:

Map param = new HashMap();
parmam.put("schema", "schemaName");
param.put("id", id);

but I only passed schema parameter for getUser sql, but I couldn't pass it 
for getAddress sql.
Now, I don't know how to pass schema parameter for getAddress sql.
Please help me to solve this problem.
Thank you very much!

View raw message