You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Ken Katsma <ke...@gmail.com> on 2005/05/17 03:01:11 UTC
Another custom type handler issue
Now that I have the custom type handler executing correctly for the nested
cursor, I have another question :)
I'm trying to use the custom type handler to populate an array of objects in
my class. For instance, I have a Client, which contains Address[] arrays and
Communication[] arrays. I'd like to populate it with a custom type handler.
While I can get the type handler to execute for a single Address or
communication object, I can't seem to find a way to get iBatis to understand
that it needs to fire a type handler for an array of those objects.
An even better way to handle this would be if there were some way I could
nest the result maps so that I point the nested cursor to a second result
map.
Any ideas?
Either way, I think I feel another hack coming on :(
Thanks,
Ken
Re: Another custom type handler issue
Posted by Ken Katsma <ke...@gmail.com>.
I would like to see an example of how the list approach might work (when
using a nested resultset). In the case of the array, I found the
solution. You just have to define the array in the custom type handler
using the format [Lpackage.ClassName; and it will fire the custom type
handler. I then am using the type handler to iterate over the nested
resultset.
If there is a way to do this using nested resultmaps it would be great,
but I haven't seen an example.
Thanks,
Ken
Brice Ruth wrote:
>Do you have to use arrays? How about lists instead? iBATIS (to my
>knowledge) doesn't support returning arrays. My guess is if you were
>to have List<Address> addresses and List<Communication> communications
>(type specification not necessary, just highlighting what its doing) -
>then iBATIS would "do the right thing".
>
>Brice
>
>On 5/16/05, Ken Katsma <ke...@gmail.com> wrote:
>
>
>>Now that I have the custom type handler executing correctly for the nested
>>cursor, I have another question :)
>>
>> I'm trying to use the custom type handler to populate an array of objects
>>in my class. For instance, I have a Client, which contains Address[] arrays
>>and Communication[] arrays. I'd like to populate it with a custom type
>>handler. While I can get the type handler to execute for a single Address
>>or communication object, I can't seem to find a way to get iBatis to
>>understand that it needs to fire a type handler for an array of those
>>objects.
>>
>> An even better way to handle this would be if there were some way I could
>>nest the result maps so that I point the nested cursor to a second result
>>map.
>>
>> Any ideas?
>>
>> Either way, I think I feel another hack coming on :(
>>
>> Thanks,
>>
>> Ken
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
>
Re: Another custom type handler issue
Posted by Brice Ruth <bd...@gmail.com>.
Do you have to use arrays? How about lists instead? iBATIS (to my
knowledge) doesn't support returning arrays. My guess is if you were
to have List<Address> addresses and List<Communication> communications
(type specification not necessary, just highlighting what its doing) -
then iBATIS would "do the right thing".
Brice
On 5/16/05, Ken Katsma <ke...@gmail.com> wrote:
> Now that I have the custom type handler executing correctly for the nested
> cursor, I have another question :)
>
> I'm trying to use the custom type handler to populate an array of objects
> in my class. For instance, I have a Client, which contains Address[] arrays
> and Communication[] arrays. I'd like to populate it with a custom type
> handler. While I can get the type handler to execute for a single Address
> or communication object, I can't seem to find a way to get iBatis to
> understand that it needs to fire a type handler for an array of those
> objects.
>
> An even better way to handle this would be if there were some way I could
> nest the result maps so that I point the nested cursor to a second result
> map.
>
> Any ideas?
>
> Either way, I think I feel another hack coming on :(
>
> Thanks,
>
> Ken
>
>
>
>
>
>
--
Brice Ruth
Software Engineer, Madison WI