ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Henrique Ferreira e Silva <dhsi...@gmail.com>
Subject Re: How to set up a select map
Date Wed, 26 Oct 2005 18:54:38 GMT
Hi Mithra,

1) Create a result-map from your expected resultset to your bean. Like:

   <resultMap id="foo">
     ....
     map your resultset fields to bean properties here
     ....
  </resultMap>

2) Create the statement:

  <select id="getAllUsers" resultMap="foo">
     select * from User
  </select>

3) In your java code do this:

    List allUsers = queryForList("getAllUsers");


You'll find more details in the Developer's Guide.

Hope that helped,
Daniel Silva.

On 10/26/05, Rajah_Mithra@emc.com <Rajah_Mithra@emc.com> wrote:
>
> Thanks a  lot! It works.
>
> I had another question as well. I want to select a full table of data;
> (Select * from User) .
> How can I collect the result? (I have a class & beans for each row & an
> array list to store the rows).
>
> Thanks,
>
>
> Mithra Rajah
>
>
>
>  ________________________________
>  From: larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] On Behalf Of
> Larry Meadors
> Sent: Wednesday, October 26, 2005 11:53 AM
> To: user-java@ibatis.apache.org
> Subject: Re: How to set up a select map
>
>
> Three ways:
>
> 1) Use "where value like #property# and put the pattern in your property.
>
> 2) Use "where value like '%' || #property# || '%'and put the value in your
> property.
>
> 3) Use "where value like '%$property$%" and put the value in your property.
>
> The last option will open you you up to SQL injection, and is generally bad
> practice. It also does not take advantage of some database vendors'
> execution plan caching.
>
> Larry
>
>
>
> On 10/26/05, Rajah_Mithra@emc.com <Rajah_Mithra@emc.com> wrote:
> >
> > Hi,
> > I want to do a pattern matching search on the database; for e.g select all
> rows that have text "ab" in them. The text can occur independantly or
> embedded. How do I do a pattern matching Select with the IBATIS map?
> > Thanks,
> >
> > Mithra Rajah
> >
>
>

Mime
View raw message