Help with iBatis nested <iterate> syntax

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Help with iBatis nested <iterate> syntax

devver
Hi

#Subsequent to the problems outline in this post: http://old.nabble.com/Problem-accessing-List-instance-property-via-%3Cisnull%3E-td28368852.html

... the problem has changed somewhat. The orignal SQL statement has been altered and we now have a structure which requries nested <iterate> elements.

It looks like patches may have been introduced into IbAtis 2.x around 2006 to enable this feature but I can't get it to work. Can someone please confirm the correct syntax? I had used somethign similar to this:

<iterate property="MyParameters.myOuterList" conjunction="OR" open="(" close=")">
     

     <iterate proeprty ="MyParameters.myOuterList[].myInnerList" conjunction="AND" open="(" close=")">

     

     </iterate>

</iterate>

Any help gratefully received. Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help with iBatis nested <iterate> syntax

Jeff Butler-2
Assuming MyParameters is some object passed as a parameter object, and
that myOuterList is a property of MyParameters:

<iterate property="myOuterList" ...>
  <iterate property="myOuterList[].myInnerList"...>
    #myOuterList[].myInnerList[].myProperty#
  </iterate>
</iterate>


Jeff Butler


On Tue, May 4, 2010 at 2:09 PM, devver <[hidden email]> wrote:

>
> Hi
>
> #Subsequent to the problems outline in this post:
> http://old.nabble.com/Problem-accessing-List-instance-property-via-%3Cisnull%3E-td28368852.html
>
> ... the problem has changed somewhat. The orignal SQL statement has been
> altered and we now have a structure which requries nested <iterate>
> elements.
>
> It looks like patches may have been introduced into IbAtis 2.x around 2006
> to enable this feature but I can't get it to work. Can someone please
> confirm the correct syntax? I had used somethign similar to this:
>
> <iterate property="MyParameters.myOuterList" conjunction="OR" open="("
> close=")">
>     <!-- Some SQL -->
>
>     <iterate proeprty ="MyParameters.myOuterList[].myInnerList"
> conjunction="AND" open="(" close=")">
>
>     <!-- More SQL where I access
> #MyParameters.myOuterList.myInnerList[].myProperty# -->
>
>     </iterate>
>
> </iterate>
>
> Any help gratefully received. Thanks
> --
> View this message in context: http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28451833.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help with iBatis nested <iterate> syntax

devver
Thanks for your reply Jeff

I am using something very similar (See below) but I am getting a host of error messages, including:

--- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal list from JavaBean. Cause java.lang.NumberFormatException: For input string: ""
Caused by: java.lang.NumberFormatException: For input string: ""; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:

followed by:

 com.ibatis.common.beans.ProbeException: Error getting ordinal list from JavaBean. Cause java.lang.NumberFormatException: For input string: ""

These are repeated several times.

I pass a HashMap into the SQLMap. One of the instances is a ReportParameters instance. This is comprised of several properties but the important one as far as my SQL is concerned is an array of objects which themselves contain an array.

My SQLMap dynanically builds a WHERE clause based on the ReportParameters 'outer' and 'inner' arrays. The <dynamic> block looks similar to this:

<iterate prepend="AND" property="ReportParameters.outerArray" conjunction="OR" open="(" close=")">
                (
                #ReportParameters.outerArray[].someProperty#
                ...
               
                )
                <iterate prepend="AND" property="ReportParameters.outerArray[].innerArray" conjunction="AND" open="(" close=")">
                        (
                           #ReportParameters.outerArray[].innerArray[].anotherProperty#
                        )
                </iterate>
        )
</iterate>

I'm not sure why this is happening at all. The syntax looks straight-forward and intuitive and yet it (or something) appears to crash iBatis.
I have dumped the contents of ReportParameters just before I execute the SQL via my DAO. Everything looks as expected.

The version of iBatis I am using is v2. The app uses ibatis-common-2.jar and ibatis-sqlmap-2.jar
Jeff Butler-2 wrote
Assuming MyParameters is some object passed as a parameter object, and
that myOuterList is a property of MyParameters:

<iterate property="myOuterList" ...>
  <iterate property="myOuterList[].myInnerList"...>
    #myOuterList[].myInnerList[].myProperty#
  </iterate>
</iterate>


Jeff Butler


On Tue, May 4, 2010 at 2:09 PM, devver <kmg203@googlemail.com> wrote:
>
> Hi
>
> #Subsequent to the problems outline in this post:
> http://old.nabble.com/Problem-accessing-List-instance-property-via-%3Cisnull%3E-td28368852.html
>
> ... the problem has changed somewhat. The orignal SQL statement has been
> altered and we now have a structure which requries nested <iterate>
> elements.
>
> It looks like patches may have been introduced into IbAtis 2.x around 2006
> to enable this feature but I can't get it to work. Can someone please
> confirm the correct syntax? I had used somethign similar to this:
>
> <iterate property="MyParameters.myOuterList" conjunction="OR" open="("
> close=")">
>    
>
>     <iterate proeprty ="MyParameters.myOuterList[].myInnerList"
> conjunction="AND" open="(" close=")">
>
>    
>
>     </iterate>
>
> </iterate>
>
> Any help gratefully received. Thanks
> --
> View this message in context: http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28451833.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help with iBatis nested <iterate> syntax

Jeff Butler-2
I think your issue relates to a misunderstanding about the "property"
attribute.  I see that you have added "ReportParameters" at the front
of all your property references.  My guess is that you don't need
that.  iBATIS would expect "ReportParameters" to be a property of your
parameter object - and I'm guessing that "ReportParameters" IS your
parameter object.  So,  remove "ReportParameters" and things will
likely improve.

Jeff Butler

On Wed, May 5, 2010 at 8:42 AM, devver <[hidden email]> wrote:

>
> Thanks for your reply Jeff
>
> I am using something very similar (See below) but I am getting a host of
> error messages, including:
>
> --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
> list from JavaBean. Cause java.lang.NumberFormatException: For input string:
> ""
> Caused by: java.lang.NumberFormatException: For input string: ""; nested
> exception is com.ibatis.common.jdbc.exception.NestedSQLException:
>
> followed by:
>
>  com.ibatis.common.beans.ProbeException: Error getting ordinal list from
> JavaBean. Cause java.lang.NumberFormatException: For input string: ""
>
> These are repeated several times.
>
> I pass a HashMap into the SQLMap. One of the instances is a ReportParameters
> instance. This is comprised of several properties but the important one as
> far as my SQL is concerned is an array of objects which themselves contain
> an array.
>
> My SQLMap dynanically builds a WHERE clause based on the ReportParameters
> 'outer' and 'inner' arrays. The <dynamic> block looks similar to this:
>
> <iterate prepend="AND" property="ReportParameters.outerArray"
> conjunction="OR" open="(" close=")">
>                (
>                #ReportParameters.outerArray[].someProperty#
>                ...
>
>                )
>                <iterate prepend="AND" property="ReportParameters.outerArray[].innerArray"
> conjunction="AND" open="(" close=")">
>                        (
>                           #ReportParameters.outerArray[].innerArray[].anotherProperty#
>                        )
>                </iterate>
>        )
> </iterate>
>
> I'm not sure why this is happening at all. The syntax looks straight-forward
> and intuitive and yet it (or something) appears to crash iBatis.
> I have dumped the contents of ReportParameters just before I execute the SQL
> via my DAO. Everything looks as expected.
>
> The version of iBatis I am using is v2. The app uses ibatis-common-2.jar and
> ibatis-sqlmap-2.jar
>
> Jeff Butler-2 wrote:
>>
>> Assuming MyParameters is some object passed as a parameter object, and
>> that myOuterList is a property of MyParameters:
>>
>> <iterate property="myOuterList" ...>
>>   <iterate property="myOuterList[].myInnerList"...>
>>     #myOuterList[].myInnerList[].myProperty#
>>   </iterate>
>> </iterate>
>>
>>
>> Jeff Butler
>>
>>
>> On Tue, May 4, 2010 at 2:09 PM, devver <[hidden email]> wrote:
>>>
>>> Hi
>>>
>>> #Subsequent to the problems outline in this post:
>>> http://old.nabble.com/Problem-accessing-List-instance-property-via-%3Cisnull%3E-td28368852.html
>>>
>>> ... the problem has changed somewhat. The orignal SQL statement has been
>>> altered and we now have a structure which requries nested <iterate>
>>> elements.
>>>
>>> It looks like patches may have been introduced into IbAtis 2.x around
>>> 2006
>>> to enable this feature but I can't get it to work. Can someone please
>>> confirm the correct syntax? I had used somethign similar to this:
>>>
>>> <iterate property="MyParameters.myOuterList" conjunction="OR" open="("
>>> close=")">
>>>     <!-- Some SQL -->
>>>
>>>     <iterate proeprty ="MyParameters.myOuterList[].myInnerList"
>>> conjunction="AND" open="(" close=")">
>>>
>>>     <!-- More SQL where I access
>>> #MyParameters.myOuterList.myInnerList[].myProperty# -->
>>>
>>>     </iterate>
>>>
>>> </iterate>
>>>
>>> Any help gratefully received. Thanks
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28451833.html
>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28461065.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help with iBatis nested <iterate> syntax

devver
Hi

It's not clear from my examples but ReportParameters is the actual name of a property in the HashMap passed to iBatis (it's used throughout the application I'm amending).

 i.e. I pass a HashMap called, say, MyHashMap to iBatis; within this is a property called ReportParameters. This in turn contains an array property called 'outerArray' whcih is comprised of several properties, one of which is another array, 'innerArray'.

My guess is that the ReportParameters.outerArray[].innerArray and #ReportParameters.outerArray[].innerArray[].someProperty# syntax should have worked as you suggest but it seems to have severe problems with accessing one of the arrays. It's almost as if it doesn#'t find an array but finds an instance of 'something else' instead.

I'm wondering whether there's an issue with the version of iBatis this particular app. uses? I'm wondering whether the nested <iterate> technique require a specific level or patch?

Jeff Butler-2 wrote
I think your issue relates to a misunderstanding about the "property"
attribute.  I see that you have added "ReportParameters" at the front
of all your property references.  My guess is that you don't need
that.  iBATIS would expect "ReportParameters" to be a property of your
parameter object - and I'm guessing that "ReportParameters" IS your
parameter object.  So,  remove "ReportParameters" and things will
likely improve.

Jeff Butler

On Wed, May 5, 2010 at 8:42 AM, devver <kmg203@googlemail.com> wrote:
>
> Thanks for your reply Jeff
>
> I am using something very similar (See below) but I am getting a host of
> error messages, including:
>
> --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
> list from JavaBean. Cause java.lang.NumberFormatException: For input string:
> ""
> Caused by: java.lang.NumberFormatException: For input string: ""; nested
> exception is com.ibatis.common.jdbc.exception.NestedSQLException:
>
> followed by:
>
>  com.ibatis.common.beans.ProbeException: Error getting ordinal list from
> JavaBean. Cause java.lang.NumberFormatException: For input string: ""
>
> These are repeated several times.
>
> I pass a HashMap into the SQLMap. One of the instances is a ReportParameters
> instance. This is comprised of several properties but the important one as
> far as my SQL is concerned is an array of objects which themselves contain
> an array.
>
> My SQLMap dynanically builds a WHERE clause based on the ReportParameters
> 'outer' and 'inner' arrays. The <dynamic> block looks similar to this:
>
> <iterate prepend="AND" property="ReportParameters.outerArray"
> conjunction="OR" open="(" close=")">
>                (
>                #ReportParameters.outerArray[].someProperty#
>                ...
>
>                )
>                <iterate prepend="AND" property="ReportParameters.outerArray[].innerArray"
> conjunction="AND" open="(" close=")">
>                        (
>                           #ReportParameters.outerArray[].innerArray[].anotherProperty#
>                        )
>                </iterate>
>        )
> </iterate>
>
> I'm not sure why this is happening at all. The syntax looks straight-forward
> and intuitive and yet it (or something) appears to crash iBatis.
> I have dumped the contents of ReportParameters just before I execute the SQL
> via my DAO. Everything looks as expected.
>
> The version of iBatis I am using is v2. The app uses ibatis-common-2.jar and
> ibatis-sqlmap-2.jar
>
> Jeff Butler-2 wrote:
>>
>> Assuming MyParameters is some object passed as a parameter object, and
>> that myOuterList is a property of MyParameters:
>>
>> <iterate property="myOuterList" ...>
>>   <iterate property="myOuterList[].myInnerList"...>
>>     #myOuterList[].myInnerList[].myProperty#
>>   </iterate>
>> </iterate>
>>
>>
>> Jeff Butler
>>
>>
>> On Tue, May 4, 2010 at 2:09 PM, devver <kmg203@googlemail.com> wrote:
>>>
>>> Hi
>>>
>>> #Subsequent to the problems outline in this post:
>>> http://old.nabble.com/Problem-accessing-List-instance-property-via-%3Cisnull%3E-td28368852.html
>>>
>>> ... the problem has changed somewhat. The orignal SQL statement has been
>>> altered and we now have a structure which requries nested <iterate>
>>> elements.
>>>
>>> It looks like patches may have been introduced into IbAtis 2.x around
>>> 2006
>>> to enable this feature but I can't get it to work. Can someone please
>>> confirm the correct syntax? I had used somethign similar to this:
>>>
>>> <iterate property="MyParameters.myOuterList" conjunction="OR" open="("
>>> close=")">
>>>    
>>>
>>>     <iterate proeprty ="MyParameters.myOuterList[].myInnerList"
>>> conjunction="AND" open="(" close=")">
>>>
>>>    
>>>
>>>     </iterate>
>>>
>>> </iterate>
>>>
>>> Any help gratefully received. Thanks
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28451833.html
>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28461065.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help with iBatis nested <iterate> syntax

Jeff Butler-2
OK.

Nested iterates work in iBATIS 2.2.0 or later.

"ReportParameters" is not really a proper Java property name - you
might try "reportParameters".  Maybe thats the problem?

Jeff Butler


On Wed, May 5, 2010 at 10:58 AM, devver <[hidden email]> wrote:

>
> Hi
>
> It's not clear from my examples but ReportParameters is the actual name of a
> property in the HashMap passed to iBatis (it's used throughout the
> application I'm amending).
>
>  i.e. I pass a HashMap called, say, MyHashMap to iBatis; within this is a
> property called ReportParameters. This in turn contains an array property
> called 'outerArray' whcih is comprised of several properties, one of which
> is another array, 'innerArray'.
>
> My guess is that the ReportParameters.outerArray[].innerArray and
> #ReportParameters.outerArray[].innerArray[].someProperty# syntax should have
> worked as you suggest but it seems to have severe problems with accessing
> one of the arrays. It's almost as if it doesn#'t find an array but finds an
> instance of 'something else' instead.
>
> I'm wondering whether there's an issue with the version of iBatis this
> particular app. uses? I'm wondering whether the nested <iterate> technique
> require a specific level or patch?
>
>
> Jeff Butler-2 wrote:
>>
>> I think your issue relates to a misunderstanding about the "property"
>> attribute.  I see that you have added "ReportParameters" at the front
>> of all your property references.  My guess is that you don't need
>> that.  iBATIS would expect "ReportParameters" to be a property of your
>> parameter object - and I'm guessing that "ReportParameters" IS your
>> parameter object.  So,  remove "ReportParameters" and things will
>> likely improve.
>>
>> Jeff Butler
>>
>> On Wed, May 5, 2010 at 8:42 AM, devver <[hidden email]> wrote:
>>>
>>> Thanks for your reply Jeff
>>>
>>> I am using something very similar (See below) but I am getting a host of
>>> error messages, including:
>>>
>>> --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
>>> list from JavaBean. Cause java.lang.NumberFormatException: For input
>>> string:
>>> ""
>>> Caused by: java.lang.NumberFormatException: For input string: ""; nested
>>> exception is com.ibatis.common.jdbc.exception.NestedSQLException:
>>>
>>> followed by:
>>>
>>>  com.ibatis.common.beans.ProbeException: Error getting ordinal list from
>>> JavaBean. Cause java.lang.NumberFormatException: For input string: ""
>>>
>>> These are repeated several times.
>>>
>>> I pass a HashMap into the SQLMap. One of the instances is a
>>> ReportParameters
>>> instance. This is comprised of several properties but the important one
>>> as
>>> far as my SQL is concerned is an array of objects which themselves
>>> contain
>>> an array.
>>>
>>> My SQLMap dynanically builds a WHERE clause based on the ReportParameters
>>> 'outer' and 'inner' arrays. The <dynamic> block looks similar to this:
>>>
>>> <iterate prepend="AND" property="ReportParameters.outerArray"
>>> conjunction="OR" open="(" close=")">
>>>                (
>>>                #ReportParameters.outerArray[].someProperty#
>>>                ...
>>>
>>>                )
>>>                <iterate prepend="AND"
>>> property="ReportParameters.outerArray[].innerArray"
>>> conjunction="AND" open="(" close=")">
>>>                        (
>>>
>>> #ReportParameters.outerArray[].innerArray[].anotherProperty#
>>>                        )
>>>                </iterate>
>>>        )
>>> </iterate>
>>>
>>> I'm not sure why this is happening at all. The syntax looks
>>> straight-forward
>>> and intuitive and yet it (or something) appears to crash iBatis.
>>> I have dumped the contents of ReportParameters just before I execute the
>>> SQL
>>> via my DAO. Everything looks as expected.
>>>
>>> The version of iBatis I am using is v2. The app uses ibatis-common-2.jar
>>> and
>>> ibatis-sqlmap-2.jar
>>>
>>> Jeff Butler-2 wrote:
>>>>
>>>> Assuming MyParameters is some object passed as a parameter object, and
>>>> that myOuterList is a property of MyParameters:
>>>>
>>>> <iterate property="myOuterList" ...>
>>>>   <iterate property="myOuterList[].myInnerList"...>
>>>>     #myOuterList[].myInnerList[].myProperty#
>>>>   </iterate>
>>>> </iterate>
>>>>
>>>>
>>>> Jeff Butler
>>>>
>>>>
>>>> On Tue, May 4, 2010 at 2:09 PM, devver <[hidden email]> wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> #Subsequent to the problems outline in this post:
>>>>> http://old.nabble.com/Problem-accessing-List-instance-property-via-%3Cisnull%3E-td28368852.html
>>>>>
>>>>> ... the problem has changed somewhat. The orignal SQL statement has
>>>>> been
>>>>> altered and we now have a structure which requries nested <iterate>
>>>>> elements.
>>>>>
>>>>> It looks like patches may have been introduced into IbAtis 2.x around
>>>>> 2006
>>>>> to enable this feature but I can't get it to work. Can someone please
>>>>> confirm the correct syntax? I had used somethign similar to this:
>>>>>
>>>>> <iterate property="MyParameters.myOuterList" conjunction="OR" open="("
>>>>> close=")">
>>>>>     <!-- Some SQL -->
>>>>>
>>>>>     <iterate proeprty ="MyParameters.myOuterList[].myInnerList"
>>>>> conjunction="AND" open="(" close=")">
>>>>>
>>>>>     <!-- More SQL where I access
>>>>> #MyParameters.myOuterList.myInnerList[].myProperty# -->
>>>>>
>>>>>     </iterate>
>>>>>
>>>>> </iterate>
>>>>>
>>>>> Any help gratefully received. Thanks
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28451833.html
>>>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28461065.html
>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28462710.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help with iBatis nested <iterate> syntax

devver
Apologies once again for the late acknowledgement of your post. Things have moved on apace.

I believe the version the applciation is precedes the 2.2.0 release which probably explains why my nested <iterates> are failing. I added the ibtatis-2.0.3.677.jar onto the classpath for no other reason that it appeared in a test application that did similar processing and suddenly things started to work. As we didn't know what else the Jar introduced int othe application and couldn't afford a huge amount of regression testing, a bespoke solution for the <iterate> problem was written in JAva instead.

Thanks again

Jeff Butler-2 wrote
OK.

Nested iterates work in iBATIS 2.2.0 or later.

"ReportParameters" is not really a proper Java property name - you
might try "reportParameters".  Maybe thats the problem?

Jeff Butler


On Wed, May 5, 2010 at 10:58 AM, devver <kmg203@googlemail.com> wrote:
>
> Hi
>
> It's not clear from my examples but ReportParameters is the actual name of a
> property in the HashMap passed to iBatis (it's used throughout the
> application I'm amending).
>
>  i.e. I pass a HashMap called, say, MyHashMap to iBatis; within this is a
> property called ReportParameters. This in turn contains an array property
> called 'outerArray' whcih is comprised of several properties, one of which
> is another array, 'innerArray'.
>
> My guess is that the ReportParameters.outerArray[].innerArray and
> #ReportParameters.outerArray[].innerArray[].someProperty# syntax should have
> worked as you suggest but it seems to have severe problems with accessing
> one of the arrays. It's almost as if it doesn#'t find an array but finds an
> instance of 'something else' instead.
>
> I'm wondering whether there's an issue with the version of iBatis this
> particular app. uses? I'm wondering whether the nested <iterate> technique
> require a specific level or patch?
>
>
> Jeff Butler-2 wrote:
>>
>> I think your issue relates to a misunderstanding about the "property"
>> attribute.  I see that you have added "ReportParameters" at the front
>> of all your property references.  My guess is that you don't need
>> that.  iBATIS would expect "ReportParameters" to be a property of your
>> parameter object - and I'm guessing that "ReportParameters" IS your
>> parameter object.  So,  remove "ReportParameters" and things will
>> likely improve.
>>
>> Jeff Butler
>>
>> On Wed, May 5, 2010 at 8:42 AM, devver <kmg203@googlemail.com> wrote:
>>>
>>> Thanks for your reply Jeff
>>>
>>> I am using something very similar (See below) but I am getting a host of
>>> error messages, including:
>>>
>>> --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
>>> list from JavaBean. Cause java.lang.NumberFormatException: For input
>>> string:
>>> ""
>>> Caused by: java.lang.NumberFormatException: For input string: ""; nested
>>> exception is com.ibatis.common.jdbc.exception.NestedSQLException:
>>>
>>> followed by:
>>>
>>>  com.ibatis.common.beans.ProbeException: Error getting ordinal list from
>>> JavaBean. Cause java.lang.NumberFormatException: For input string: ""
>>>
>>> These are repeated several times.
>>>
>>> I pass a HashMap into the SQLMap. One of the instances is a
>>> ReportParameters
>>> instance. This is comprised of several properties but the important one
>>> as
>>> far as my SQL is concerned is an array of objects which themselves
>>> contain
>>> an array.
>>>
>>> My SQLMap dynanically builds a WHERE clause based on the ReportParameters
>>> 'outer' and 'inner' arrays. The <dynamic> block looks similar to this:
>>>
>>> <iterate prepend="AND" property="ReportParameters.outerArray"
>>> conjunction="OR" open="(" close=")">
>>>                (
>>>                #ReportParameters.outerArray[].someProperty#
>>>                ...
>>>
>>>                )
>>>                <iterate prepend="AND"
>>> property="ReportParameters.outerArray[].innerArray"
>>> conjunction="AND" open="(" close=")">
>>>                        (
>>>
>>> #ReportParameters.outerArray[].innerArray[].anotherProperty#
>>>                        )
>>>                </iterate>
>>>        )
>>> </iterate>
>>>
>>> I'm not sure why this is happening at all. The syntax looks
>>> straight-forward
>>> and intuitive and yet it (or something) appears to crash iBatis.
>>> I have dumped the contents of ReportParameters just before I execute the
>>> SQL
>>> via my DAO. Everything looks as expected.
>>>
>>> The version of iBatis I am using is v2. The app uses ibatis-common-2.jar
>>> and
>>> ibatis-sqlmap-2.jar
>>>
>>> Jeff Butler-2 wrote:
>>>>
>>>> Assuming MyParameters is some object passed as a parameter object, and
>>>> that myOuterList is a property of MyParameters:
>>>>
>>>> <iterate property="myOuterList" ...>
>>>>   <iterate property="myOuterList[].myInnerList"...>
>>>>     #myOuterList[].myInnerList[].myProperty#
>>>>   </iterate>
>>>> </iterate>
>>>>
>>>>
>>>> Jeff Butler
>>>>
>>>>
>>>> On Tue, May 4, 2010 at 2:09 PM, devver <kmg203@googlemail.com> wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> #Subsequent to the problems outline in this post:
>>>>> http://old.nabble.com/Problem-accessing-List-instance-property-via-%3Cisnull%3E-td28368852.html
>>>>>
>>>>> ... the problem has changed somewhat. The orignal SQL statement has
>>>>> been
>>>>> altered and we now have a structure which requries nested <iterate>
>>>>> elements.
>>>>>
>>>>> It looks like patches may have been introduced into IbAtis 2.x around
>>>>> 2006
>>>>> to enable this feature but I can't get it to work. Can someone please
>>>>> confirm the correct syntax? I had used somethign similar to this:
>>>>>
>>>>> <iterate property="MyParameters.myOuterList" conjunction="OR" open="("
>>>>> close=")">
>>>>>    
>>>>>
>>>>>     <iterate proeprty ="MyParameters.myOuterList[].myInnerList"
>>>>> conjunction="AND" open="(" close=")">
>>>>>
>>>>>    
>>>>>
>>>>>     </iterate>
>>>>>
>>>>> </iterate>
>>>>>
>>>>> Any help gratefully received. Thanks
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28451833.html
>>>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28461065.html
>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Help-with-iBatis-nested-%3Citerate%3E-syntax-tp28451833p28462710.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Loading...