You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Dimiter Kapitanov (JIRA)" <ib...@incubator.apache.org> on 2005/02/07 15:18:12 UTC
[jira] Commented: (IBATIS-51) Nulls interpretted incorrectly in version 2.0.9
[ http://issues.apache.org/jira/browse/IBATIS-51?page=comments#action_58675 ]
Dimiter Kapitanov commented on IBATIS-51:
-----------------------------------------
It seems iBatis developers are quite busy. So I checked the sources.
The reason is in class :
com.ibatis.common.beans.ComplexBeanProbe.java (rows 248 and 275)
In iBatis DBL 2.0.7 they were :
hasProperty = ((Map) object).containsKey(propertyName);
now in iBatis 2.0.9 it is :
hasProperty = true;//((Map) object).containsKey(propertyName);
So - if you use Map as parameter object, iBatis thinks any property exist.
This broke 'the contract' and back compatibility (any regression tests ?).
My suggestion is : please restore previous behaviour. Our applications rely on it.
Thank you for your attention.
> Nulls interpretted incorrectly in version 2.0.9
> -----------------------------------------------
>
> Key: IBATIS-51
> URL: http://issues.apache.org/jira/browse/IBATIS-51
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.0.9
> Environment: MySQL 3.23.x
> Reporter: Dimiter Kapitanov
>
> When use HashMap as parameter class, SQL query is consturcted (with nulls) even for missing properties.
> This is new bug, appeared in iBatis DBL 2.0.9 (it didn't exist in iBatis DBL 2.0.7).
> Demonstration code :
> -------------------------
> [M.java]
> import com.ibatis.sqlmap.client.SqlMapClient;
> import com.ibatis.sqlmap.client.SqlMapClientBuilder;
> import java.io.*;
> import java.util.*;
> /**
> * Test for bug in iBatis DBL 2.0.9.
> */
> public class M
> {
> public static void main(String[] args)
> {
> System.out.println("Testing iBatis DBL 2.0.9 bug : ");
> System.out.println("If you run this program with iBatis 2.0.7 it " +
> "will return result, if you run it with iBatis 2.0.9 it will " +
> "return null.");
>
> try
> {
> String mapFile = "DB_Config.xml";
> Reader reader = new FileReader(mapFile);
> SqlMapClient mapper = SqlMapClientBuilder.buildSqlMapClient(
> reader);
>
> HashMap m = new HashMap();
> m.put("name", "Am");
> Map result = (Map)mapper.queryForObject("selectAccount", m);
>
> System.out.println("Result = " + result);
> }
> catch (Exception exc)
> {
> exc.printStackTrace();
> }
> }
> }
> -------------------------
> [DB_Config.xml]
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
> <sqlMapConfig>
> <properties resource="debug.ini"/>
> <transactionManager type="JDBC">
> <dataSource type="SIMPLE">
> <property value="${DB_DRIVER}" name="JDBC.Driver"/>
> <property value="${DB_URL}" name="JDBC.ConnectionURL"/>
> <property value="${DB_USER}" name="JDBC.Username"/>
> <property value="${DB_PASSWORD}" name="JDBC.Password"/>
> <property value="${DB_QUERY}" name="Pool.PingQuery"/>
> <property value="15" name="Pool.MaximumActiveConnections"/>
> <property value="15" name="Pool.MaximumIdleConnections"/>
> <property value="1000" name="Pool.MaximumWait"/>
> </dataSource>
> </transactionManager>
> <sqlMap resource="Account.xml"/>
>
> </sqlMapConfig>
> -------------------------
> [Account.xml]
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
> "http://www.ibatis.com/dtd/sql-map-2.dtd">
> <sqlMap>
> <statement id="selectAccount" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
> SELECT * FROM table1
> <dynamic prepend="WHERE">
> <isPropertyAvailable prepend="AND" property="id">
> id = #id#
> </isPropertyAvailable>
> <isPropertyAvailable prepend="AND" property="name">
> name = #name#
> </isPropertyAvailable>
> </dynamic>
> ORDER BY name
> </statement>
> </sqlMap>
> ---------------------
> [debug.sql]
> #
> # testDB SQL script (uses MySQL 3.23.x).
> #
> CREATE DATABASE testDB;
> GRANT ALL PRIVILEGES ON testDB.* TO 'testDB'@'localhost' IDENTIFIED BY 'testDB';
> FLUSH PRIVILEGES;
> use testDB;
> CREATE TABLE table1 (
> id int unsigned NOT NULL auto_increment primary key,
> name varchar(20)
> );
> insert into table1 values (1, 'Am');
> insert into table1 values (2, 'Tam');
> ---------------------
> [debug.ini]
> #
> # testDB settings.
> #
> DB_DRIVER=com.mysql.jdbc.Driver
> DB_URL=jdbc:mysql://localhost/testDB?useUnicode=true
> DB_USER=testDB
> DB_PASSWORD=testDB
> DB_QUERY=select 1 from table1
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira