How to "select" with more than one parameter ?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to "select" with more than one parameter ?

Haim Schindler
How to "select" using more than one parameter ?

I could not figure it out from the documentation.
ALL the "select" examples in the documentation use only ONE parameter
#{id}

How to select something like that:

<select id=”selectSome” >
      SELECT * FROM PERSON
       WHERE
                   ID = #{id}
                   AND
                   eyesColor = #{eyesColor}
                   AND
                   height > #{minHeight}
</select>

Can I define a select as above ?
and define the function in the mapper as:

List<Persopn> selectSome(Integer id, String eyesColor, int minHeight);

?
Reply | Threaded
Open this post in threaded view
|

Re: How to "select" with more than one parameter ?

Jackie Li
You can use a Person object as the passed in Parameter, then refer its attributes as the expected column values.

Cheers,
Jackie


On Mon, Feb 21, 2011 at 23:08, haim <[hidden email]> wrote:
How to "select" using more than one parameter ?

I could not figure it out from the documentation.
ALL the "select" examples in the documentation use only ONE parameter
#{id}

How to select something like that:

<select id=”selectSome” >
     SELECT * FROM PERSON
      WHERE
                  ID = #{id}
                  AND
                  eyesColor = #{eyesColor}
                  AND
                  height > #{minHeight}
</select>

Can I define a select as above ?
and define the function in the mapper as:

List<Persopn> selectSome(Integer id, String eyesColor, int minHeight);

?

Reply | Threaded
Open this post in threaded view
|

Re: How to "select" with more than one parameter ?

François Schiettecatte
You can also use a HashMap as well.

François

On Feb 21, 2011, at 10:14 AM, lwpro wrote:

> You can use a Person object as the passed in Parameter, then refer its attributes as the expected column values.
>
> Cheers,
> Jackie
>
>
> On Mon, Feb 21, 2011 at 23:08, haim <[hidden email]> wrote:
> How to "select" using more than one parameter ?
>
> I could not figure it out from the documentation.
> ALL the "select" examples in the documentation use only ONE parameter
> #{id}
>
> How to select something like that:
>
> <select id=”selectSome” >
>      SELECT * FROM PERSON
>       WHERE
>                   ID = #{id}
>                   AND
>                   eyesColor = #{eyesColor}
>                   AND
>                   height > #{minHeight}
> </select>
>
> Can I define a select as above ?
> and define the function in the mapper as:
>
> List<Persopn> selectSome(Integer id, String eyesColor, int minHeight);
>
> ?
>

Reply | Threaded
Open this post in threaded view
|

Re: How to "select" with more than one parameter ?

Nathan Maves
In reply to this post by Jackie Li
you can also define the parameters

List<Persopn> selectSome(@Param("id")Integer id, @Param("eyesColor")String eyesColor, @Param("minHeight")int minHeight);

On Mon, Feb 21, 2011 at 8:14 AM, lwpro <[hidden email]> wrote:
You can use a Person object as the passed in Parameter, then refer its attributes as the expected column values.

Cheers,
Jackie



On Mon, Feb 21, 2011 at 23:08, haim <[hidden email]> wrote:
How to "select" using more than one parameter ?

I could not figure it out from the documentation.
ALL the "select" examples in the documentation use only ONE parameter
#{id}

How to select something like that:

<select id=”selectSome” >
     SELECT * FROM PERSON
      WHERE
                  ID = #{id}
                  AND
                  eyesColor = #{eyesColor}
                  AND
                  height > #{minHeight}
</select>

Can I define a select as above ?
and define the function in the mapper as:

List<Persopn> selectSome(Integer id, String eyesColor, int minHeight);

?


Reply | Threaded
Open this post in threaded view
|

Re: How to "select" with more than one parameter ?

Haim Schindler
thank you all
what a fast reply, i did not expect.... :)
I will check the suggestions...

On Mon, Feb 21, 2011 at 5:18 PM, Nathan Maves <[hidden email]> wrote:
you can also define the parameters

List<Persopn> selectSome(@Param("id")Integer id, @Param("eyesColor")String eyesColor, @Param("minHeight")int minHeight);

On Mon, Feb 21, 2011 at 8:14 AM, lwpro <[hidden email]> wrote:
You can use a Person object as the passed in Parameter, then refer its attributes as the expected column values.

Cheers,
Jackie



On Mon, Feb 21, 2011 at 23:08, haim <[hidden email]> wrote:
How to "select" using more than one parameter ?

I could not figure it out from the documentation.
ALL the "select" examples in the documentation use only ONE parameter
#{id}

How to select something like that:

<select id=”selectSome” >
     SELECT * FROM PERSON
      WHERE
                  ID = #{id}
                  AND
                  eyesColor = #{eyesColor}
                  AND
                  height > #{minHeight}
</select>

Can I define a select as above ?
and define the function in the mapper as:

List<Persopn> selectSome(Integer id, String eyesColor, int minHeight);

?