Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 47121 invoked from network); 20 Jul 2008 17:57:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Jul 2008 17:57:40 -0000 Received: (qmail 74155 invoked by uid 500); 20 Jul 2008 17:57:33 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 74140 invoked by uid 500); 20 Jul 2008 17:57:33 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 74129 invoked by uid 99); 20 Jul 2008 17:57:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Jul 2008 10:57:33 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [213.52.246.188] (HELO MAIL.DIOSPHERE.com) (213.52.246.188) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 20 Jul 2008 17:56:40 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C8EA91.A0734308" Subject: RE: Bug with complex property in result map? X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Sun, 20 Jul 2008 18:57:05 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Bug with complex property in result map? Thread-Index: AcjoDsLK1i8fWd+fTyumOVobDPJrCwCgR+Lw References: From: "Dragan Jotanovic" To: X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------_=_NextPart_001_01C8EA91.A0734308 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Has anyone noticed this bug? I can't believe that no one has stumbled upon this. =20 Dragan =20 From: Dragan Jotanovic [mailto:Dragan.Jotanovic@DIOSPHERE.com]=20 Sent: Thursday, July 17, 2008 2:12 PM To: user-java@ibatis.apache.org Subject: Bug with complex property in result map? =20 Hi there, I noticed that after upgrading to newer version of iBatis, some of the functionality that used to work with iBatis 2.0.9 stopped working. Namely, the problem occurred in case when there is complex property in result map. Here is the simple test case: - Sql map: =20 =20 =20 =20 =20 - class A(id, description); class B (id, a_id, object A) =20 - TABLE_A(id, description){(1, 'rec 1'), (2, 'rec 2')} - TABLE_B(id, a_id){(1, 1), (1, null)} =20 As you can see, a_id field in TABLE_B is nullable.=20 When you invoke queryForList("getAllB"), iBatis breaks with following exception: com.ibatis.common.jdbc.exception.NestedSQLException: =20 --- The error occurred in Test.xml. =20 --- The error occurred while applying a result map. =20 --- Check the Test.resultB. =20 --- Check the result mapping for the 'a' property. =20 --- Cause: java.lang.NullPointerException at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryW ithCallback(MappedStatement.java:204) at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryF orList(MappedStatement.java:139) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMap ExecutorDelegate.java:567) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMap ExecutorDelegate.java:541) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessi onImpl.java:118) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClient Impl.java:94) at TestIbatis.main(TestIbatis.java:28) Caused by: java.lang.NullPointerException at java.lang.Class.isAssignableFrom(Native Method) at com.ibatis.sqlmap.engine.type.TypeHandlerFactory.getTypeHandler(TypeHand lerFactory.java:143) at com.ibatis.sqlmap.engine.type.TypeHandlerFactory.getTypeHandler(TypeHand lerFactory.java:123) at com.ibatis.sqlmap.engine.mapping.result.ResultMap.prepareBeanParameterOb ject(ResultMap.java:591) at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getNestedSelectMapping Value(ResultMap.java:475) at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getResults(ResultMap.j ava:341) at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor .java:384) at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(Sql Executor.java:300) at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor. java:189) at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQue ry(MappedStatement.java:221) at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryW ithCallback(MappedStatement.java:189) ... 6 more =20 What I would expect is that for those null values in database, value of property A in class B to be set to null. This used to work in version 2.0.9, and was broken after version 2.2 I think. I tried with latest 2.3.3 as well with the same result. Is this a known issue, or maybe a feature? Is there some simple workaround for the problem? I am aware that above solution is not perfect (problem of N+1 selects), but we already implemented a lot of queries this way and it would be time consuming to rewrite them all. =20 Dragan ------_=_NextPart_001_01C8EA91.A0734308 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Has anyone noticed = this bug? I can’t believe that no one has stumbled upon = this.

 

Dragan

 

From:= Dragan = Jotanovic [mailto:Dragan.Jotanovic@DIOSPHERE.com]
Sent: Thursday, July 17, 2008 2:12 PM
To: user-java@ibatis.apache.org
Subject: Bug with complex property in result = map?

 

Hi there,

I noticed that after upgrading to newer version of = iBatis, some of the functionality that used to work with iBatis 2.0.9 stopped = working.

Namely, the problem occurred in case when there is = complex property in result map.

Here is the simple test case:

- Sql map:

 

  <resultMap id=3D"resultA" class=3D"A">

    <result = property=3D"id" column=3D"ID"/>

    <result property=3D"description" = column=3D"DESCRIPTION"/>

  </resultMap>

 

  <resultMap id=3D"resultB" class=3D"B">

    <result = property=3D"id" column=3D"ID"/>

    <result = property=3D"a_id" column=3D"A_ID"/>

    <result property=3D"a" column=3D"A_ID" = select=3D"getA"/>

  </resultMap>

 

  <select id=3D"getAllB" resultMap=3D"resultB">

    select * from = TABLE_B

  </select>

 

  <select id=3D"getA" resultMap=3D"resultA">

    select * from = TABLE_A

    where = id=3D#value#

  </select>

 

- class A(id, description); class B (id, a_id, = object A)

 

- TABLE_A(id, description){(1, rec 1), (2, rec 2)}

- TABLE_B(id, a_id){(1, 1), (1, null)}

 

As you can see, a_id field in TABLE_B is nullable. =

When you invoke = queryForList(“getAllB”), iBatis breaks with following exception:

com.ibatis.common.jdbc.exception.NestedSQLException:  

--- The error occurred in = Test.xml. 

--- The error occurred while = applying a result map. 

--- Check the Test.resultB.  =

--- Check the result mapping for = the 'a' property. 

--- Cause: java.lang.NullPointerException

      at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWi= thCallback(MappedStatement.java:204)

      at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryFo= rList(MappedStatement.java:139)

      at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(= SqlMapExecutorDelegate.java:567)

      at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(= SqlMapExecutorDelegate.java:541)

      at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)

      at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:94)

      at TestIbatis.main(TestIbatis.java:28)

Caused by: java.lang.NullPointerException

      at java.lang.Class.isAssignableFrom(Native Method)

      at com.ibatis.sqlmap.engine.type.TypeHandlerFactory.getTypeHandler(TypeHandlerFactory.java:143)

      at com.ibatis.sqlmap.engine.type.TypeHandlerFactory.getTypeHandler(TypeHandlerFactory.java:123)

      at com.ibatis.sqlmap.engine.mapping.result.ResultMap.prepareBeanParameterObj= ect(ResultMap.java:591)

      at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getNestedSelectMappingV= alue(ResultMap.java:475)

      at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getResults(ResultMap.java:341)

      at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:384)

      at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:300)

      at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:189)

      at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuer= y(MappedStatement.java:221)

      at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWi= thCallback(MappedStatement.java:189)

      ... 6 = more

 

What I would expect is that for those null values in database, value of = property A in class B to be set to = null.

This used to work in version 2.0.9, and was broken after version 2.2 I think. = I tried with latest 2.3.3 as well with the same = result.

Is this a known issue, or maybe a feature? Is there some simple workaround = for the problem? I am aware that above solution is not perfect (problem of N+1 selects), but we already implemented a lot of queries this way and it = would be time consuming to rewrite them all.

 

Dragan

------_=_NextPart_001_01C8EA91.A0734308--