[ http://issues.apache.org/jira/browse/IBATIS-281?page=comments#action_12411991 ]
Jeff Butler commented on IBATIS-281: ------------------------------------ I'd like to use this issue as a catch all issue for problems with the iterate tag. Please feel free to add additional use cases that fail if you find them (I am already aware of IBATIS-293 so no need to repeat that here). Christian - thanks for your work on this issue! Could you please elaborate on the comment you made 05/May/2006? Are you proposing a different fix than your original patches, or is the comment related to another issue? I'm trying not to duplicate all your research. My status so far... I've writen a set of test cases that demonstrate various failures of the iterate tag. The general classes of failures are these: 1. Nested iterates where the nested iterate tags are dependant on the parent tags 2. Nested iterates where the nested iterate tags are independant of the parent tags (i.e. iterating over two seperate properties - kind of like nested for loops) 3. Conditional tags inside iterates fail if the the first element of the iterate does not meet the condition Christian's patches solve problem #1 as far as I can tell, but not the others. I believe I have a fix for #3, and I've not started to figure out why #2 doesn't work yet. > 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 > Assignee: Jeff Butler > 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