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 Ashish Kulkarni <ku...@yahoo.com> on 2006/02/28 18:07:09 UTC

Get ResultSet using ibatis

Hi
Is it possible to get Resultset as resultClass after
running a query
Suppose i have a query like below
select * from mytable
how do i define <select...> in xml file so i can get a
resultset as output from it
I will parse this resultset into objects i need

Ashish

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Get ResultSet using ibatis

Posted by Sven Boden <li...@pandora.be>.
For your problem forget the IBATIS-53 examples... How about something as:

  <resultMap id="some-result-map" class="MyTest">
    <result property="first" column="A"/>
    <result property="second" column="B"/>
    <result property="third" column="C"/>
  </resultMap>

as resultmap.... mapping from sql to properties.

Regards,
Sven

Ashish Kulkarni wrote:

>Hi
>
>I am still not sure how to use
>http://issues.apache.org/jira/browse/IBATIS-53 for my
>soultion.
>
>This is my real problem and need to find a work around
>I have a SQL statement which returns about 50 values,
>and there a java class with get and set methods, 
>but the data names in SQL statement do not match that
>of java class.
>for example 
>
>my sql statement is as below
>
>SELECT A AS A, B AS B, C AS C FROM MYTABLE
>
>where as my java class is as below with get and set
>methods
>
>public class MyTest
>private String first;
>private String second;
>private String third;
>
>Now i want to Map A to first, B to second and C to
>third.
>
>Unfortunaletly i cannot redefine SQL statement or java
>class as it is too much effort
>
>Any solution to get it working
>(I am trying to modify a old project using ibatis, in
>my previous project we used raw JDBC and prepared
>statements to get resultset)
>
>
>Ashish
>
>
>
>--- Sven Boden <li...@pandora.be> wrote:
>
>  
>
>>Hi Ashish,
>>
>>Have a look at
>>http://issues.apache.org/jira/browse/IBATIS-53 for
>>some 
>>examples of what you can probably use. It's not
>>really the primary use 
>>of iBATIS, but it works ;-)
>>
>>Regards,
>>Sven
>>
>>Ashish Kulkarni wrote:
>>
>>    
>>
>>>Hi
>>>Is it possible to get Resultset as resultClass
>>>      
>>>
>>after
>>    
>>
>>>running a query
>>>Suppose i have a query like below
>>>select * from mytable
>>>how do i define <select...> in xml file so i can
>>>      
>>>
>>get a
>>    
>>
>>>resultset as output from it
>>>I will parse this resultset into objects i need
>>>
>>>Ashish
>>>
>>>__________________________________________________
>>>Do You Yahoo!?
>>>Tired of spam?  Yahoo! Mail has the best spam
>>>      
>>>
>>protection around 
>>    
>>
>>>http://mail.yahoo.com 
>>>
>>>
>>> 
>>>
>>>      
>>>
>>    
>>
>
>
>A$HI$H
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>
>  
>


Re: Get ResultSet using ibatis

Posted by Diran Ayandele <Ad...@Sun.COM>.
Ashish, Maybe I am not understanding your problem, but I don't see why 
you can't map your properties in a result map.  It certainly meets your 
criteria of not changing the sql or java class.  Anyway it looks like this:


    <resultMap id="MyMap" class="your.Class">
        <result property="a" column="first" />
        <result property="b" column="second"/>  
        <result property="c" column="third" />
    </resultMap>

Diran

Ashish Kulkarni wrote:

>Hi
>
>I am still not sure how to use
>http://issues.apache.org/jira/browse/IBATIS-53 for my
>soultion.
>
>This is my real problem and need to find a work around
>I have a SQL statement which returns about 50 values,
>and there a java class with get and set methods, 
>but the data names in SQL statement do not match that
>of java class.
>for example 
>
>my sql statement is as below
>
>SELECT A AS A, B AS B, C AS C FROM MYTABLE
>
>where as my java class is as below with get and set
>methods
>
>public class MyTest
>private String first;
>private String second;
>private String third;
>
>Now i want to Map A to first, B to second and C to
>third.
>
>Unfortunaletly i cannot redefine SQL statement or java
>class as it is too much effort
>
>Any solution to get it working
>(I am trying to modify a old project using ibatis, in
>my previous project we used raw JDBC and prepared
>statements to get resultset)
>
>
>Ashish
>
>
>
>--- Sven Boden <li...@pandora.be> wrote:
>
>  
>
>>Hi Ashish,
>>
>>Have a look at
>>http://issues.apache.org/jira/browse/IBATIS-53 for
>>some 
>>examples of what you can probably use. It's not
>>really the primary use 
>>of iBATIS, but it works ;-)
>>
>>Regards,
>>Sven
>>
>>Ashish Kulkarni wrote:
>>
>>    
>>
>>>Hi
>>>Is it possible to get Resultset as resultClass
>>>      
>>>
>>after
>>    
>>
>>>running a query
>>>Suppose i have a query like below
>>>select * from mytable
>>>how do i define <select...> in xml file so i can
>>>      
>>>
>>get a
>>    
>>
>>>resultset as output from it
>>>I will parse this resultset into objects i need
>>>
>>>Ashish
>>>
>>>__________________________________________________
>>>Do You Yahoo!?
>>>Tired of spam?  Yahoo! Mail has the best spam
>>>      
>>>
>>protection around 
>>    
>>
>>>http://mail.yahoo.com 
>>>
>>>
>>> 
>>>
>>>      
>>>
>>    
>>
>
>
>A$HI$H
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>  
>

Re: Get ResultSet using ibatis

Posted by Ashish Kulkarni <ku...@yahoo.com>.
Hi

I am still not sure how to use
http://issues.apache.org/jira/browse/IBATIS-53 for my
soultion.

This is my real problem and need to find a work around
I have a SQL statement which returns about 50 values,
and there a java class with get and set methods, 
but the data names in SQL statement do not match that
of java class.
for example 

my sql statement is as below

SELECT A AS A, B AS B, C AS C FROM MYTABLE

where as my java class is as below with get and set
methods

public class MyTest
private String first;
private String second;
private String third;

Now i want to Map A to first, B to second and C to
third.

Unfortunaletly i cannot redefine SQL statement or java
class as it is too much effort

Any solution to get it working
(I am trying to modify a old project using ibatis, in
my previous project we used raw JDBC and prepared
statements to get resultset)


Ashish



--- Sven Boden <li...@pandora.be> wrote:

> Hi Ashish,
> 
> Have a look at
> http://issues.apache.org/jira/browse/IBATIS-53 for
> some 
> examples of what you can probably use. It's not
> really the primary use 
> of iBATIS, but it works ;-)
> 
> Regards,
> Sven
> 
> Ashish Kulkarni wrote:
> 
> >Hi
> >Is it possible to get Resultset as resultClass
> after
> >running a query
> >Suppose i have a query like below
> >select * from mytable
> >how do i define <select...> in xml file so i can
> get a
> >resultset as output from it
> >I will parse this resultset into objects i need
> >
> >Ashish
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> >http://mail.yahoo.com 
> >
> >
> >  
> >
> 
> 


A$HI$H

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Get ResultSet using ibatis

Posted by Sven Boden <li...@pandora.be>.
Hi Ashish,

Have a look at http://issues.apache.org/jira/browse/IBATIS-53 for some 
examples of what you can probably use. It's not really the primary use 
of iBATIS, but it works ;-)

Regards,
Sven

Ashish Kulkarni wrote:

>Hi
>Is it possible to get Resultset as resultClass after
>running a query
>Suppose i have a query like below
>select * from mytable
>how do i define <select...> in xml file so i can get a
>resultset as output from it
>I will parse this resultset into objects i need
>
>Ashish
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>
>  
>