You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Christian Poitras (JIRA)" <ib...@incubator.apache.org> on 2006/04/03 17:22:25 UTC

[jira] Commented: (IBATIS-281) Nested iterate tags does not work

    [ http://issues.apache.org/jira/browse/IBATIS-281?page=comments#action_12372958 ] 

Christian Poitras commented on IBATIS-281:
------------------------------------------

In the description, the exception is caused because BeanProbe tries to call the following method from parameter class.
getList(new java.Integer(""))

It generates the error provided in the description.
In fact the property accessed by the following nested iterate tags is as follow.
<iterate property="list">
  <iterate property="list[].list">
    #list[].list[].property#
  </iterate>
</iterate>

The property accessed is "list[].list[0].property" in the first iteration (no other iterations are made).

> Nested iterate tags does not work
> ---------------------------------
>
>          Key: IBATIS-281
>          URL: http://issues.apache.org/jira/browse/IBATIS-281
>      Project: iBatis for Java
>         Type: Bug

>   Components: SQL Maps
>     Versions: 2.1.7
>     Reporter: Christian Poitras
>  Attachments: ConditionalTagHandler.java, DynamicSql.java, IterateTagHandler.java
>
> No nested iterate tags work. The second iterate tag is not supported and produces the following error.
> java.lang.NumberFormatException: For input string: ""
> at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
> at java.lang.Integer.parseInt(Integer.java:489)
> at java.lang.Integer.parseInt(Integer.java:518)
> at com.ibatis.common.beans.BaseProbe.getIndexedProperty(BaseProbe.java:51)
> at com.ibatis.common.beans.ComplexBeanProbe.getProperty(ComplexBeanProbe.java:297)
> at com.ibatis.common.beans.ComplexBeanProbe.getObject(ComplexBeanProbe.java:188)
> at com.ibatis.common.beans.GenericProbe.getObject(GenericProbe.java:76)
> at com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.IterateTagHandler.doStartFragment(IterateTagHandler.java:34)
> at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.processBodyChildren(DynamicSql.java:157)
> at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.processBodyChildren(DynamicSql.java:160)
> at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.processBodyChildren(DynamicSql.java:99)
> at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.process(DynamicSql.java:79)
> at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.getParameterMap(DynamicSql.java:61)
> at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:156)
> at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
> at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
> at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
> at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
> at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
> at com.ibatis.dao.client.template.SqlMapDaoTemplate.queryForList(SqlMapDaoTemplate.java:203)
> at ca.qc.ircm.lana.persistence.sqlmapdao.SpotSqlMapDao.getSpotsInter(SpotSqlMapDao.java:159)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at com.ibatis.dao.engine.impl.DaoProxy.invoke(DaoProxy.java:72)
> at $Proxy14.getSpotsInter(Unknown Source)
> at ca.qc.ircm.lana.service.InterpretationService.getSpotsInter(InterpretationService.java:82)
> at TEST.testInterpretation.main(testInterpretation.java:111)
> It seems the second iterate tag cannot have a property of this type.
> <iterate property="list" >
>   <iterate property="list[].list">
>   <iterate>
> </iterate>
> On the nested iterate, SQL Maps does not add the number in attribute property "list[].list" and tries to call a getter for parameterClass.getList[]() and this is not allowed and produces the error.
> This could be prevented in the IterateTagHandler class (doStartFragment method) by adding code that replaces "[]" in the property attribute by values of IterateContext that are parents of the current tag (for multiple nested iterate).
> Other code would need to be updated since using a property in the second list also causes SQL Map to crash even it IterateTagHandler is patched.
> <iterate property="list" >
>   <iterate property="list[].list">
>     #list[].list[].someProperty#
>   <iterate>
> </iterate>
> I produced a patch that can correct the problem. I will include it in a future message.

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira