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 Filipe David Manana <fd...@ieee.org> on 2008/04/21 15:21:54 UTC
select multiple fields query
Hi,
I am a beginner regarding iBATIS (Java version). I want to map a select
query that returns rows of 2 fields. My sql map is:
<select id="getClusterNames" resultClass="String">
SELECT DISTINCT clustername, clustertype
FROM vwhost
</select>
Using this mapping I get a List of Strings, but only values for the
clustername field.
I would like to get, for example, a List of Lists (each inner list would
have exactly 2 strings).
Using "List" as the resultClass I get a List of empty Lists :(
How can I get the 2 columns?
cheers
--
Filipe David Manana,
fdmanana@ieee.org
"The cruellest lies are often told in silence."
Re: select multiple fields query
Posted by Kambix <ka...@mgm-tp.com>.
Hello Larry,
in the above example; can I get only the second column back with
resultClass="String"
without resultmap? I mean how can I map it?
I have a group by query with more than one column, but only one of them is
to be mapped
(the first one in this case). How can I do it whithout defining a class for
it?
<select id="Chk_Vordruck" resultClass="String">
SELECT formular_vordruck_name AS Vordruck_Name,
Formular_UFA AS Unterfallart,
MIN(formular_jahr) AS min_jahr,
MAX(formular_jahr) AS max_jahr
FROM Formular
GROUP BY formular_vordruck_name,
Formular_UFA
</select>
thank you
regards
kambiz
Larry Meadors wrote:
>
> You can't currently get a list of lists, but you can get a list of maps:
>
> <select id="getClusterNames" resultClass="hashmap">
>
> Larry
>
>
> On Mon, Apr 21, 2008 at 7:21 AM, Filipe David Manana <fd...@ieee.org>
> wrote:
>> Hi,
>>
>> I am a beginner regarding iBATIS (Java version). I want to map a select
>> query that returns rows of 2 fields. My sql map is:
>>
>> <select id="getClusterNames" resultClass="String">
>> SELECT DISTINCT clustername, clustertype
>> FROM vwhost
>> </select>
>>
>> Using this mapping I get a List of Strings, but only values for the
>> clustername field.
>> I would like to get, for example, a List of Lists (each inner list would
>> have exactly 2 strings).
>> Using "List" as the resultClass I get a List of empty Lists :(
>> How can I get the 2 columns?
>>
>> cheers
>>
>> --
>> Filipe David Manana,
>> fdmanana@ieee.org
>>
>> "The cruellest lies are often told in silence."
>
>
--
View this message in context: http://www.nabble.com/select-multiple-fields-query-tp16810325p24415042.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
Re: select multiple fields query
Posted by Larry Meadors <la...@gmail.com>.
Depends on the driver, some will let you use "double quotes" to control that.
Larry
On Mon, Apr 21, 2008 at 8:43 AM, Filipe David Manana <fd...@ieee.org> wrote:
> Thanks, it works nice :)
> I notice the Map's keys are always strings in uppercase. Is it possible to
> control the case?
>
> cheers
>
>
>
> On Mon, Apr 21, 2008 at 3:59 PM, Larry Meadors <la...@gmail.com>
> wrote:
>
> > You can't currently get a list of lists, but you can get a list of maps:
> >
> > <select id="getClusterNames" resultClass="hashmap">
> >
> > Larry
> >
> >
> >
> >
> >
> > On Mon, Apr 21, 2008 at 7:21 AM, Filipe David Manana <fd...@ieee.org>
> wrote:
> > > Hi,
> > >
> > > I am a beginner regarding iBATIS (Java version). I want to map a select
> > > query that returns rows of 2 fields. My sql map is:
> > >
> > > <select id="getClusterNames" resultClass="String">
> > > SELECT DISTINCT clustername, clustertype
> > > FROM vwhost
> > > </select>
> > >
> > > Using this mapping I get a List of Strings, but only values for the
> > > clustername field.
> > > I would like to get, for example, a List of Lists (each inner list would
> > > have exactly 2 strings).
> > > Using "List" as the resultClass I get a List of empty Lists :(
> > > How can I get the 2 columns?
> > >
> > > cheers
> > >
> > > --
> > > Filipe David Manana,
> > > fdmanana@ieee.org
> > >
> > > "The cruellest lies are often told in silence."
> >
>
>
>
> --
>
> Filipe David Manana,
> fdmanana@ieee.org
>
> "The cruellest lies are often told in silence."
Re: select multiple fields query
Posted by Filipe David Manana <fd...@ieee.org>.
Thanks, it works nice :)
I notice the Map's keys are always strings in uppercase. Is it possible to
control the case?
cheers
On Mon, Apr 21, 2008 at 3:59 PM, Larry Meadors <la...@gmail.com>
wrote:
> You can't currently get a list of lists, but you can get a list of maps:
>
> <select id="getClusterNames" resultClass="hashmap">
>
> Larry
>
>
> On Mon, Apr 21, 2008 at 7:21 AM, Filipe David Manana <fd...@ieee.org>
> wrote:
> > Hi,
> >
> > I am a beginner regarding iBATIS (Java version). I want to map a select
> > query that returns rows of 2 fields. My sql map is:
> >
> > <select id="getClusterNames" resultClass="String">
> > SELECT DISTINCT clustername, clustertype
> > FROM vwhost
> > </select>
> >
> > Using this mapping I get a List of Strings, but only values for the
> > clustername field.
> > I would like to get, for example, a List of Lists (each inner list would
> > have exactly 2 strings).
> > Using "List" as the resultClass I get a List of empty Lists :(
> > How can I get the 2 columns?
> >
> > cheers
> >
> > --
> > Filipe David Manana,
> > fdmanana@ieee.org
> >
> > "The cruellest lies are often told in silence."
>
--
Filipe David Manana,
fdmanana@ieee.org
"The cruellest lies are often told in silence."
Re: select multiple fields query
Posted by Larry Meadors <la...@gmail.com>.
You can't currently get a list of lists, but you can get a list of maps:
<select id="getClusterNames" resultClass="hashmap">
Larry
On Mon, Apr 21, 2008 at 7:21 AM, Filipe David Manana <fd...@ieee.org> wrote:
> Hi,
>
> I am a beginner regarding iBATIS (Java version). I want to map a select
> query that returns rows of 2 fields. My sql map is:
>
> <select id="getClusterNames" resultClass="String">
> SELECT DISTINCT clustername, clustertype
> FROM vwhost
> </select>
>
> Using this mapping I get a List of Strings, but only values for the
> clustername field.
> I would like to get, for example, a List of Lists (each inner list would
> have exactly 2 strings).
> Using "List" as the resultClass I get a List of empty Lists :(
> How can I get the 2 columns?
>
> cheers
>
> --
> Filipe David Manana,
> fdmanana@ieee.org
>
> "The cruellest lies are often told in silence."