Alright.. don't waste your time, it works fine as one would expect when
given proper input. Sorry about that, I'm usually more thorough before
resorting to mailing lists
On 5/21/2010 11:33 AM, Alex Sherwin wrote:
> Method is annotated with @InsertProvider, my implementation method
> takes a Map<String, Object> and can see the array passed in keyed with
> "array" (I also explicitly set its name with @Param to be sure it was
> consitent in my sql provider and where it creates the prepared
> statement values)
>
> Generated sql in java:
> INSERT INTO test (id, field) VALUES (#{array[0].id},
> #{array[0].field}), (#{array[1].id}, #{array[1].field}),
> (#{array[2].id}, #{array[2].field})
>
> However, when the sql is run with a array of 3 objects, which in order
> have id's 1,2,3 and field values "field1", "field2", "field3", in this
> case it only populated the values for the last item in the array, and
> into the second position of the parameter values..
>
> ==> Executing: INSERT INTO test (id, field) VALUES (?, ?), (?, ?),
> (?, ?)
> ==> Parameters: null, null, 3, field3(String), null, null
>
> This isn't the behavior one would expect, no?
>
> On 5/21/2010 11:10 AM, Jeff Butler wrote:
>> Yes - that works. iBATIS is using OGNL to interpret the parameters,
>> so any valid OGNL expression works.
>>
>> Jeff Butler
>>
>>
>> On Fri, May 21, 2010 at 10:04 AM, Alex Sherwin
>> <alex.sherwin@acadiasoft.com> wrote:
>>> On 5/21/2010 10:23 AM, Alex Sherwin wrote:
>>>> I just want to make sure, but there is there simply no way to pass
>>>> arguments to the sql provider method defined in the annotations
>>>> such as
>>>> @InsertProvider?
>>>>
>>>> It would be very beneficial to be able to do so in terms of building
>>>> dynamic sql, such as an insert statements for a dynamic number of rows
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>>
>>>>
>>>>
>>> After stepping through the code I've answered my own question, I
>>> don't know
>>> how I missed that before; and I also see it underlined specifically
>>> in the
>>> documentation.. missed that as well somehow.
>>>
>>> My next question is, which the documentation doesn't touch upon, is
>>> there a
>>> notation for directly accessing members of an array or list?
>>> Ultimately, my
>>> question is, in a java sql provider, can I pass in a List/Array of
>>> objects
>>> and generate (pseudo) sql such as this:
>>>
>>> insert into tbl (id, field) values (#{ilst[0].id}, #{list[0].field},
>>> #{list[1].id}, #{list[2].id}, .. )
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> 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
|