You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Jerry Jalenak <Je...@LABONE.com> on 2005/05/20 22:05:56 UTC

iBatis 2.0.9 Dynamic Statement Problem

I'm not sure if this came through the first time or not, so I'm resending it. I apologize in advance if this is a double post.....


All,

I'm using 2.0.9 w/ a dynamic statement (passing in a Map), but it doesn't appear to be building the PreparedStatement completely.

<code>

    public void getUserInfo(UserInfo ui)
        throws SQLException
    {
        Map m = new HashMap();
        m.put("lastName", ui.getLastName() + "%");
        m.put("firstName", ui.getFirstName() + "%");
        m.put("dob", ui.getDob());
        m.put("patientId", ui.getPatientId());

        SqlMapClient sqlMap = getSqlMapClient();
        try
        {
            ui = (UserInfo) sqlMap.queryForObject("getUserInformation", m, ui);
        }
        catch(SQLException sqle)
        {}
        finally
        {
            m = null;
        }
    }

</code>

<sqlmap>

    <select id="getUserInformation" resultMap="UserInformation">
        SELECT ext_patient_id, insured_first_name, insured_last_name, member_ssn, carrier_num, pcs_group_id, 
            insured_dob, eff_begin_date, eff_end_date, app_addr1, app_addr2, city, state_code, zip_code, 
            order_received_dte, order_sent_dte, order_status, relation_code 
        FROM labcard_eligibility
        WHERE relation_code = '00' and carrier_num ^= 'UNIVERSAL'
        <dynamic>
            <isNotEmpty prepend="AND" property="lastName">
                insured_last_name LIKE #lastName#
            </isNotEmpty>
            <isNotEmpty prepend="AND" property="firstName">
                insured_first_name LIKE #firstName# 
            </isNotEmpty>
            <isNotEmpty prepend="AND" property="dob">
                insured_dob = #dob# 
            </isNotEmpty>
            <isNotEmpty prepend="AND" property="patientID">
                (ext_patient_id = $patientId$ or member_ssn = $patientId$)
            </isNotEmpty>
        </dynamic>

    </select>
</sqlmap>

<log4j output>

DEBUG 05/20/2005:11:33:14 - Created connection 5872987.
DEBUG 05/20/2005:11:33:14 - {pstm-100001} PreparedStatement:    SELECT ext_patient_id, insured_first_name, insured_last_name, member_ssn, carrier_num, pcs_group_id,     insured_dob, eff_begin_date, eff_end_date, app_addr1, app_addr2, city, state_code, zip_code,     order_received_dte, order_sent_dte, order_status, relation_code    FROM labcard_eligibility   WHERE relation_code = '00' and carrier_num ^= 'UNIVERSAL'       AND     insured_last_name LIKE ?        AND     insured_first_name LIKE ?                  
DEBUG 05/20/2005:11:33:14 - {pstm-100001} Parameters: [REYNOLDS%, RICHARD%]
DEBUG 05/20/2005:11:33:14 - {pstm-100001} Types: [java.lang.String, java.lang.String]
DEBUG 05/20/2005:11:33:15 - Returned connection 5872987 to pool.

</log4j output>

From the DEBUG trace, it looks like it's only substituting the lastName and firstName attributes.  I've stopped the code and inspected the Map, and the other data elements (dob and patientID) are in the Map.  Is this a bug in 2.0.9?  or have I screwed something up? 

Thanks!

Jerry Jalenak
Senior Programmer / Analyst, Client Management
LabOne, Inc.
10101 Renner Blvd.
Lenexa, KS  66219
(913) 577-1496

jerry.jalenak@labone.com


This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at the following email address: securityincidentreporting@labone.com