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 Tomáš Procházka <t....@centrum.cz> on 2009/10/04 21:00:00 UTC

two parametr in Mapper method

Why not supported this?

@Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
 List getAllItems(int offset, int limit);


Its limitation of Java or bug in actual version?

 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: two parametr in Mapper method

Posted by Tomáš Procházka <t....@centrum.cz>.
I wrote this:
http://issues.apache.org/jira/browse/IBATIS-669

______________________________________________________________
> Od: "Clinton Begin" <cl...@gmail.com>
> Komu: user-java@ibatis.apache.org
> Datum: 05.10.2009 16:11
> Předmět: Re: two parametr in Mapper method
>
>You should create a Jira ticket, as I don't think anyone has on this subject
>yet.
>
>2009/10/5 Tomáš Procházka <t....@centrum.cz>
>
>>
>> Hi.
>>
>> This would be great, booth possibilities! Its in plan do this in 3.0
>> release?
>>
>> -------------------------- Original message --------------------------
>>  From: Clinton Begin <cl...@gmail.com>
>>  Subject: two parametr in Mapper method
>>  Date: Monday, October 5, 2009, 4:52:08 AM
>> Attachments: Zpráva.html
>>  msgid:16178eb10910041952u5ad70db3ja712c1a7ed7628a4@mail.gmail.com<ms...@mail.gmail.com>
>>
>>
>> There's no way to introspect on the parameter names.
>>
>>
>>
>> So your choices become:
>>
>>
>>
>> @Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
>> List getAllItems(int offset, int limit);
>>
>>
>>
>> ...Or...
>>
>>
>>
>> @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>> List getAllItems(@Param("offset") int offset, @Param("limit") int limit);
>>
>>
>>
>> Both suck. But we'll probably default to the first, and allow for the
>> second.
>>
>>
>> ------------------------ Konec původní zprávy ------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: two parametr in Mapper method

Posted by Clinton Begin <cl...@gmail.com>.
You should create a Jira ticket, as I don't think anyone has on this subject
yet.

2009/10/5 Tomáš Procházka <t....@centrum.cz>

>
> Hi.
>
> This would be great, booth possibilities! Its in plan do this in 3.0
> release?
>
> -------------------------- Original message --------------------------
>  From: Clinton Begin <cl...@gmail.com>
>  Subject: two parametr in Mapper method
>  Date: Monday, October 5, 2009, 4:52:08 AM
> Attachments: Zpráva.html
>  msgid:16178eb10910041952u5ad70db3ja712c1a7ed7628a4@mail.gmail.com<ms...@mail.gmail.com>
>
>
> There's no way to introspect on the parameter names.
>
>
>
> So your choices become:
>
>
>
> @Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
> List getAllItems(int offset, int limit);
>
>
>
> ...Or...
>
>
>
> @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
> List getAllItems(@Param("offset") int offset, @Param("limit") int limit);
>
>
>
> Both suck. But we'll probably default to the first, and allow for the
> second.
>
>
> ------------------------ Konec původní zprávy ------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: two parametr in Mapper method

Posted by Tomáš Procházka <t....@centrum.cz>.
Hi.

This would be great, booth possibilities! Its in plan do this in 3.0 release?

-------------------------- Original message --------------------------
 From: Clinton Begin <cl...@gmail.com>
 Subject: two parametr in Mapper method
 Date: Monday, October 5, 2009, 4:52:08 AM
Attachments: Zpráva.html
 msgid:16178eb10910041952u5ad70db3ja712c1a7ed7628a4@mail.gmail.com


There's no way to introspect on the parameter names. 



So your choices become:



@Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
List getAllItems(int offset, int limit);



...Or...



@Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
List getAllItems(@Param("offset") int offset, @Param("limit") int limit);



Both suck. But we'll probably default to the first, and allow for the second.


------------------------ Konec původní zprávy ------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: two parametr in Mapper method

Posted by Clinton Begin <cl...@gmail.com>.
Ah, no problem.  If you do leave out the annotation, the variables will
simply be named in order, like:  #{1}, #{2}, etc.
Clinton

2009/10/13 Tomáš Procházka <t....@centrum.cz>

>
> No. I think that when I use XML, anotation is not necessary. This was my
> fault. Thanks you.
>
> ______________________________________________________________
> > Od: "Clinton Begin" <cl...@gmail.com>
> > Komu: user-java@ibatis.apache.org
> > Datum: 13.10.2009 12:45
> > Předmět: Re: two parametr in Mapper method
> >
> >In your second XML example, are you still using the same method signature?
> >
> >Like this:
> >
> >List<Send> getAllItems(@Param("offset") int offset, @Param("limit") int
> >limit);
> >
> ><?xml version="1.0" encoding="UTF-8" ?>
> ><!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "
> >http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
> ><mapper namespace="cz.apache.ibatis.SendMapper">
> >       <select id="getAllItemsX" parameterType="map"
> >resultType="cz.apache.ibatis.Send" >
> >               select * from send LIMIT #{offset}, #{limit}
> >       </select>
> >
> ></mapper>
> >
> >
> >Clinton
> >
> >2009/10/12 Tomáš Procházka <t....@centrum.cz>
> >
> >>
> >> I tested it and it doesn't works for me.
> >>
> >> This works great now:
> >>
> >>        @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
> >>         List<Send> getAllItems(@Param("offset") int offset,
> @Param("limit")
> >> int limit);
> >>
> >> but this not:
> >>
> >> <?xml version="1.0" encoding="UTF-8" ?>
> >> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "
> >> http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
> >> <mapper namespace="cz.apache.ibatis.SendMapper">
> >>        <select id="getAllItemsX" parameterType="map"
> >> resultType="cz.apache.ibatis.Send" >
> >>                select * from send LIMIT #{offset}, #{limit}
> >>        </select>
> >>
> >> </mapper>
> >>
> >>
> >> I got:
> >>
> >> Exception in thread "main" org.apache.ibatis.exceptions.IbatisException:
> >> ### Error querying database.  Cause:
> org.apache.ibatis.type.TypeException:
> >> JDBC requires that the JdbcType must be specified for all nullable
> >> parameters.
> >> ### The error may exist in SendMapper.xml
> >> ### The error may involve
> cz.apache.ibatis.SendMapper.getAllItemsX-Inline
> >> ### The error occurred while setting parameters
> >> ### SQL: select * from send LIMIT ?, ?
> >> ### Cause: org.apache.ibatis.type.TypeException: JDBC requires that the
> >> JdbcType must be specified for all nullable parameters.
> >>        at
> >>
> org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
> >>
> >>
> >> How Can I specify parametr types?
> >>
> >> ______________________________________________________________
> >> > Od: "Clinton Begin" <cl...@gmail.com>
> >> > Komu: user-java@ibatis.apache.org
> >> > Datum: 06.10.2009 09:33
> >> > Předmět: Re: two parametr in Mapper method
> >> >
> >> >multiple parameters will require the XML equivalent parameter type to
> be
> >> >Map.  Behind the scenes, it will do exactly what you do today -- wrap
> >> >multiple params in a Map.  This keeps it simple and consistent.
> >> >Clinton
> >> >
> >> >On Mon, Oct 5, 2009 at 12:23 AM, Guy Rouillier <guyr-ml1@burntmail.com
> >> >wrote:
> >> >
> >> >> I'm glad to see you are considering allowing multiple parameters.
>  I've
> >> >> found having to bind everything into one is cumbersome.
> >> >>
> >> >> What are you thinking of doing for XML?  I'd suggest replacing
> >> >> ParameterType with ParameterList, with the latter a cut and paste
> from
> >> the
> >> >> mapper method.  Your example below would look like:
> >> >>
> >> >> parameterList="int offset, int limit"
> >> >>
> >> >> From a programmer's perspective, I'd find the cut and paste easy, and
> >> >> iBatis would have everything it needs to enable named parameters in
> the
> >> SQL.
> >> >>
> >> >> Clinton Begin wrote:
> >> >>
> >> >>> There's no way to introspect on the parameter names.
> >> >>> So your choices become:
> >> >>>
> >> >>> @Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
> >> >>> List getAllItems(int offset, int limit);
> >> >>>
> >> >>> ...Or...
> >> >>>
> >> >>> @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
> >> >>> List getAllItems(@Param("offset") int offset, @Param("limit") int
> >> limit);
> >> >>>
> >> >>> Both suck. But we'll probably default to the first, and allow for
> the
> >> >>> second.
> >> >>> Gross.
> >> >>>
> >> >>> Clinton
> >> >>>
> >> >>> On Sun, Oct 4, 2009 at 8:00 PM, Guy Rouillier <
> guyr-ml1@burntmail.com
> >> <mailto:
> >> >>> guyr-ml1@burntmail.com>> wrote:
> >> >>>
> >> >>>    I'd be curious to understand what the Java limitation is.  I
> would
> >> >>>    have thought that with Java 1.5's support of varargs, limitations
> >> >>>    such as this would no longer exists.  Of course, to use varargs
> >> >>>    here, I suppose we'd have to use Object[], which would shoot your
> >> >>>    type safety.
> >> >>>
> >> >>>    Clinton Begin wrote:
> >> >>>
> >> >>>        It's a limitation in Java.  However, we are working on a
> couple
> >> >>>        of potential options.  But it's not possible to do it the way
> >> >>>        you've written it (which is really sad, because it's
> perfectly
> >> >>>        possible in C# and other languages).
> >> >>>
> >> >>>        Clinton
> >> >>>
> >> >>>        2009/10/4 Tomáš Procházka <t.prochazka@centrum.cz
> >> >>>        <ma...@centrum.cz> <mailto:
> t.prochazka@centrum.cz
> >> >>>        <ma...@centrum.cz>>>
> >> >>>
> >> >>>
> >> >>>
> >> >>>           Why not supported this?
> >> >>>
> >> >>>           @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
> >> >>>            List getAllItems(int offset, int limit);
> >> >>>
> >> >>>
> >> >>>           Its limitation of Java or bug in actual version?
> >> >>>
> >> >>>
> >> >>>
> ---------------------------------------------------------------------
> >> >>>           To unsubscribe, e-mail:
> >> >>>        user-java-unsubscribe@ibatis.apacheorg
> >> >>>        <ma...@ibatis.apache.org>
> >> >>>           <mailto:user-java-unsubscribe@ibatis.apache.org
> >> >>>        <ma...@ibatis.apache.org>>
> >> >>>
> >> >>>           For additional commands, e-mail:
> >> >>>        user-java-help@ibatis.apache.org
> >> >>>        <ma...@ibatis.apache.org>
> >> >>>           <mailto:user-java-help@ibatis.apache.org
> >> >>>        <ma...@ibatis.apache.org>>
> >> >>>
> >> >>>
> >> >>>
> >> >>>
> >> >>>    --    Guy Rouillier
> >> >>>
> >> >>>
> >> >>>
> >>  ---------------------------------------------------------------------
> >> >>>    To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> >> >>>    <ma...@ibatis.apache.org>
> >> >>>    For additional commands, e-mail:
> user-java-help@ibatis.apache.org
> >> >>>    <ma...@ibatis.apache.org>
> >> >>>
> >> >>>
> >> >>>
> >> >>
> >> >> --
> >> >> Guy Rouillier
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> >> >> For additional commands, e-mail: user-java-help@ibatis.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> >> For additional commands, e-mail: user-java-help@ibatis.apache.org
> >>
> >>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: two parametr in Mapper method

Posted by Tomáš Procházka <t....@centrum.cz>.
No. I think that when I use XML, anotation is not necessary. This was my fault. Thanks you.

______________________________________________________________
> Od: "Clinton Begin" <cl...@gmail.com>
> Komu: user-java@ibatis.apache.org
> Datum: 13.10.2009 12:45
> Předmět: Re: two parametr in Mapper method
>
>In your second XML example, are you still using the same method signature?
>
>Like this:
>
>List<Send> getAllItems(@Param("offset") int offset, @Param("limit") int
>limit);
>
><?xml version="1.0" encoding="UTF-8" ?>
><!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "
>http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
><mapper namespace="cz.apache.ibatis.SendMapper">
>       <select id="getAllItemsX" parameterType="map"
>resultType="cz.apache.ibatis.Send" >
>               select * from send LIMIT #{offset}, #{limit}
>       </select>
>
></mapper>
>
>
>Clinton
>
>2009/10/12 Tomáš Procházka <t....@centrum.cz>
>
>>
>> I tested it and it doesn't works for me.
>>
>> This works great now:
>>
>>        @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>>         List<Send> getAllItems(@Param("offset") int offset, @Param("limit")
>> int limit);
>>
>> but this not:
>>
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "
>> http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
>> <mapper namespace="cz.apache.ibatis.SendMapper">
>>        <select id="getAllItemsX" parameterType="map"
>> resultType="cz.apache.ibatis.Send" >
>>                select * from send LIMIT #{offset}, #{limit}
>>        </select>
>>
>> </mapper>
>>
>>
>> I got:
>>
>> Exception in thread "main" org.apache.ibatis.exceptions.IbatisException:
>> ### Error querying database.  Cause: org.apache.ibatis.type.TypeException:
>> JDBC requires that the JdbcType must be specified for all nullable
>> parameters.
>> ### The error may exist in SendMapper.xml
>> ### The error may involve cz.apache.ibatis.SendMapper.getAllItemsX-Inline
>> ### The error occurred while setting parameters
>> ### SQL: select * from send LIMIT ?, ?
>> ### Cause: org.apache.ibatis.type.TypeException: JDBC requires that the
>> JdbcType must be specified for all nullable parameters.
>>        at
>> org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
>>
>>
>> How Can I specify parametr types?
>>
>> ______________________________________________________________
>> > Od: "Clinton Begin" <cl...@gmail.com>
>> > Komu: user-java@ibatis.apache.org
>> > Datum: 06.10.2009 09:33
>> > Předmět: Re: two parametr in Mapper method
>> >
>> >multiple parameters will require the XML equivalent parameter type to be
>> >Map.  Behind the scenes, it will do exactly what you do today -- wrap
>> >multiple params in a Map.  This keeps it simple and consistent.
>> >Clinton
>> >
>> >On Mon, Oct 5, 2009 at 12:23 AM, Guy Rouillier <guyr-ml1@burntmail.com
>> >wrote:
>> >
>> >> I'm glad to see you are considering allowing multiple parameters.  I've
>> >> found having to bind everything into one is cumbersome.
>> >>
>> >> What are you thinking of doing for XML?  I'd suggest replacing
>> >> ParameterType with ParameterList, with the latter a cut and paste from
>> the
>> >> mapper method.  Your example below would look like:
>> >>
>> >> parameterList="int offset, int limit"
>> >>
>> >> From a programmer's perspective, I'd find the cut and paste easy, and
>> >> iBatis would have everything it needs to enable named parameters in the
>> SQL.
>> >>
>> >> Clinton Begin wrote:
>> >>
>> >>> There's no way to introspect on the parameter names.
>> >>> So your choices become:
>> >>>
>> >>> @Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
>> >>> List getAllItems(int offset, int limit);
>> >>>
>> >>> ...Or...
>> >>>
>> >>> @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>> >>> List getAllItems(@Param("offset") int offset, @Param("limit") int
>> limit);
>> >>>
>> >>> Both suck. But we'll probably default to the first, and allow for the
>> >>> second.
>> >>> Gross.
>> >>>
>> >>> Clinton
>> >>>
>> >>> On Sun, Oct 4, 2009 at 8:00 PM, Guy Rouillier <guyr-ml1@burntmail.com
>> <mailto:
>> >>> guyr-ml1@burntmail.com>> wrote:
>> >>>
>> >>>    I'd be curious to understand what the Java limitation is.  I would
>> >>>    have thought that with Java 1.5's support of varargs, limitations
>> >>>    such as this would no longer exists.  Of course, to use varargs
>> >>>    here, I suppose we'd have to use Object[], which would shoot your
>> >>>    type safety.
>> >>>
>> >>>    Clinton Begin wrote:
>> >>>
>> >>>        It's a limitation in Java.  However, we are working on a couple
>> >>>        of potential options.  But it's not possible to do it the way
>> >>>        you've written it (which is really sad, because it's perfectly
>> >>>        possible in C# and other languages).
>> >>>
>> >>>        Clinton
>> >>>
>> >>>        2009/10/4 Tomáš Procházka <t.prochazka@centrum.cz
>> >>>        <ma...@centrum.cz> <mailto:t.prochazka@centrum.cz
>> >>>        <ma...@centrum.cz>>>
>> >>>
>> >>>
>> >>>
>> >>>           Why not supported this?
>> >>>
>> >>>           @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>> >>>            List getAllItems(int offset, int limit);
>> >>>
>> >>>
>> >>>           Its limitation of Java or bug in actual version?
>> >>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>>           To unsubscribe, e-mail:
>> >>>        user-java-unsubscribe@ibatis.apacheorg
>> >>>        <ma...@ibatis.apache.org>
>> >>>           <mailto:user-java-unsubscribe@ibatis.apache.org
>> >>>        <ma...@ibatis.apache.org>>
>> >>>
>> >>>           For additional commands, e-mail:
>> >>>        user-java-help@ibatis.apache.org
>> >>>        <ma...@ibatis.apache.org>
>> >>>           <mailto:user-java-help@ibatis.apache.org
>> >>>        <ma...@ibatis.apache.org>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>>    --    Guy Rouillier
>> >>>
>> >>>
>> >>>
>>  ---------------------------------------------------------------------
>> >>>    To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> >>>    <ma...@ibatis.apache.org>
>> >>>    For additional commands, e-mail: user-java-help@ibatis.apache.org
>> >>>    <ma...@ibatis.apache.org>
>> >>>
>> >>>
>> >>>
>> >>
>> >> --
>> >> Guy Rouillier
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> >> For additional commands, e-mail: user-java-help@ibatis.apache.org
>> >>
>> >>
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: two parametr in Mapper method

Posted by Clinton Begin <cl...@gmail.com>.
In your second XML example, are you still using the same method signature?

Like this:

List<Send> getAllItems(@Param("offset") int offset, @Param("limit") int
limit);

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "
http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="cz.apache.ibatis.SendMapper">
       <select id="getAllItemsX" parameterType="map"
resultType="cz.apache.ibatis.Send" >
               select * from send LIMIT #{offset}, #{limit}
       </select>

</mapper>


Clinton

2009/10/12 Tomáš Procházka <t....@centrum.cz>

>
> I tested it and it doesn't works for me.
>
> This works great now:
>
>        @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>         List<Send> getAllItems(@Param("offset") int offset, @Param("limit")
> int limit);
>
> but this not:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "
> http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
> <mapper namespace="cz.apache.ibatis.SendMapper">
>        <select id="getAllItemsX" parameterType="map"
> resultType="cz.apache.ibatis.Send" >
>                select * from send LIMIT #{offset}, #{limit}
>        </select>
>
> </mapper>
>
>
> I got:
>
> Exception in thread "main" org.apache.ibatis.exceptions.IbatisException:
> ### Error querying database.  Cause: org.apache.ibatis.type.TypeException:
> JDBC requires that the JdbcType must be specified for all nullable
> parameters.
> ### The error may exist in SendMapper.xml
> ### The error may involve cz.apache.ibatis.SendMapper.getAllItemsX-Inline
> ### The error occurred while setting parameters
> ### SQL: select * from send LIMIT ?, ?
> ### Cause: org.apache.ibatis.type.TypeException: JDBC requires that the
> JdbcType must be specified for all nullable parameters.
>        at
> org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
>
>
> How Can I specify parametr types?
>
> ______________________________________________________________
> > Od: "Clinton Begin" <cl...@gmail.com>
> > Komu: user-java@ibatis.apache.org
> > Datum: 06.10.2009 09:33
> > Předmět: Re: two parametr in Mapper method
> >
> >multiple parameters will require the XML equivalent parameter type to be
> >Map.  Behind the scenes, it will do exactly what you do today -- wrap
> >multiple params in a Map.  This keeps it simple and consistent.
> >Clinton
> >
> >On Mon, Oct 5, 2009 at 12:23 AM, Guy Rouillier <guyr-ml1@burntmail.com
> >wrote:
> >
> >> I'm glad to see you are considering allowing multiple parameters.  I've
> >> found having to bind everything into one is cumbersome.
> >>
> >> What are you thinking of doing for XML?  I'd suggest replacing
> >> ParameterType with ParameterList, with the latter a cut and paste from
> the
> >> mapper method.  Your example below would look like:
> >>
> >> parameterList="int offset, int limit"
> >>
> >> From a programmer's perspective, I'd find the cut and paste easy, and
> >> iBatis would have everything it needs to enable named parameters in the
> SQL.
> >>
> >> Clinton Begin wrote:
> >>
> >>> There's no way to introspect on the parameter names.
> >>> So your choices become:
> >>>
> >>> @Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
> >>> List getAllItems(int offset, int limit);
> >>>
> >>> ...Or...
> >>>
> >>> @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
> >>> List getAllItems(@Param("offset") int offset, @Param("limit") int
> limit);
> >>>
> >>> Both suck. But we'll probably default to the first, and allow for the
> >>> second.
> >>> Gross.
> >>>
> >>> Clinton
> >>>
> >>> On Sun, Oct 4, 2009 at 8:00 PM, Guy Rouillier <guyr-ml1@burntmail.com
> <mailto:
> >>> guyr-ml1@burntmail.com>> wrote:
> >>>
> >>>    I'd be curious to understand what the Java limitation is.  I would
> >>>    have thought that with Java 1.5's support of varargs, limitations
> >>>    such as this would no longer exists.  Of course, to use varargs
> >>>    here, I suppose we'd have to use Object[], which would shoot your
> >>>    type safety.
> >>>
> >>>    Clinton Begin wrote:
> >>>
> >>>        It's a limitation in Java.  However, we are working on a couple
> >>>        of potential options.  But it's not possible to do it the way
> >>>        you've written it (which is really sad, because it's perfectly
> >>>        possible in C# and other languages).
> >>>
> >>>        Clinton
> >>>
> >>>        2009/10/4 Tomáš Procházka <t.prochazka@centrum.cz
> >>>        <ma...@centrum.cz> <mailto:t.prochazka@centrum.cz
> >>>        <ma...@centrum.cz>>>
> >>>
> >>>
> >>>
> >>>           Why not supported this?
> >>>
> >>>           @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
> >>>            List getAllItems(int offset, int limit);
> >>>
> >>>
> >>>           Its limitation of Java or bug in actual version?
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>>           To unsubscribe, e-mail:
> >>>        user-java-unsubscribe@ibatis.apacheorg
> >>>        <ma...@ibatis.apache.org>
> >>>           <mailto:user-java-unsubscribe@ibatis.apache.org
> >>>        <ma...@ibatis.apache.org>>
> >>>
> >>>           For additional commands, e-mail:
> >>>        user-java-help@ibatis.apache.org
> >>>        <ma...@ibatis.apache.org>
> >>>           <mailto:user-java-help@ibatis.apache.org
> >>>        <ma...@ibatis.apache.org>>
> >>>
> >>>
> >>>
> >>>
> >>>    --    Guy Rouillier
> >>>
> >>>
> >>>
>  ---------------------------------------------------------------------
> >>>    To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> >>>    <ma...@ibatis.apache.org>
> >>>    For additional commands, e-mail: user-java-help@ibatis.apache.org
> >>>    <ma...@ibatis.apache.org>
> >>>
> >>>
> >>>
> >>
> >> --
> >> Guy Rouillier
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> >> For additional commands, e-mail: user-java-help@ibatis.apache.org
> >>
> >>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: two parametr in Mapper method

Posted by Tomáš Procházka <t....@centrum.cz>.
I tested it and it doesn't works for me.

This works great now:

        @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
        List<Send> getAllItems(@Param("offset") int offset, @Param("limit") int limit);

but this not:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="cz.apache.ibatis.SendMapper">
        <select id="getAllItemsX" parameterType="map" resultType="cz.apache.ibatis.Send" >
                select * from send LIMIT #{offset}, #{limit}
        </select>

</mapper>


I got:

Exception in thread "main" org.apache.ibatis.exceptions.IbatisException: 
### Error querying database.  Cause: org.apache.ibatis.type.TypeException: JDBC requires that the JdbcType must be specified for all nullable parameters.
### The error may exist in SendMapper.xml
### The error may involve cz.apache.ibatis.SendMapper.getAllItemsX-Inline
### The error occurred while setting parameters
### SQL: select * from send LIMIT ?, ?
### Cause: org.apache.ibatis.type.TypeException: JDBC requires that the JdbcType must be specified for all nullable parameters.
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)


How Can I specify parametr types?

______________________________________________________________
> Od: "Clinton Begin" <cl...@gmail.com>
> Komu: user-java@ibatis.apache.org
> Datum: 06.10.2009 09:33
> Předmět: Re: two parametr in Mapper method
>
>multiple parameters will require the XML equivalent parameter type to be
>Map.  Behind the scenes, it will do exactly what you do today -- wrap
>multiple params in a Map.  This keeps it simple and consistent.
>Clinton
>
>On Mon, Oct 5, 2009 at 12:23 AM, Guy Rouillier <gu...@burntmail.com>wrote:
>
>> I'm glad to see you are considering allowing multiple parameters.  I've
>> found having to bind everything into one is cumbersome.
>>
>> What are you thinking of doing for XML?  I'd suggest replacing
>> ParameterType with ParameterList, with the latter a cut and paste from the
>> mapper method.  Your example below would look like:
>>
>> parameterList="int offset, int limit"
>>
>> From a programmer's perspective, I'd find the cut and paste easy, and
>> iBatis would have everything it needs to enable named parameters in the SQL.
>>
>> Clinton Begin wrote:
>>
>>> There's no way to introspect on the parameter names.
>>> So your choices become:
>>>
>>> @Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
>>> List getAllItems(int offset, int limit);
>>>
>>> ...Or...
>>>
>>> @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>>> List getAllItems(@Param("offset") int offset, @Param("limit") int limit);
>>>
>>> Both suck. But we'll probably default to the first, and allow for the
>>> second.
>>> Gross.
>>>
>>> Clinton
>>>
>>> On Sun, Oct 4, 2009 at 8:00 PM, Guy Rouillier <guyr-ml1@burntmail.com<mailto:
>>> guyr-ml1@burntmail.com>> wrote:
>>>
>>>    I'd be curious to understand what the Java limitation is.  I would
>>>    have thought that with Java 1.5's support of varargs, limitations
>>>    such as this would no longer exists.  Of course, to use varargs
>>>    here, I suppose we'd have to use Object[], which would shoot your
>>>    type safety.
>>>
>>>    Clinton Begin wrote:
>>>
>>>        It's a limitation in Java.  However, we are working on a couple
>>>        of potential options.  But it's not possible to do it the way
>>>        you've written it (which is really sad, because it's perfectly
>>>        possible in C# and other languages).
>>>
>>>        Clinton
>>>
>>>        2009/10/4 Tomáš Procházka <t.prochazka@centrum.cz
>>>        <ma...@centrum.cz> <mailto:t.prochazka@centrum.cz
>>>        <ma...@centrum.cz>>>
>>>
>>>
>>>
>>>           Why not supported this?
>>>
>>>           @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>>>            List getAllItems(int offset, int limit);
>>>
>>>
>>>           Its limitation of Java or bug in actual version?
>>>
>>>
>>> ---------------------------------------------------------------------
>>>           To unsubscribe, e-mail:
>>>        user-java-unsubscribe@ibatis.apacheorg
>>>        <ma...@ibatis.apache.org>
>>>           <mailto:user-java-unsubscribe@ibatis.apache.org
>>>        <ma...@ibatis.apache.org>>
>>>
>>>           For additional commands, e-mail:
>>>        user-java-help@ibatis.apache.org
>>>        <ma...@ibatis.apache.org>
>>>           <mailto:user-java-help@ibatis.apache.org
>>>        <ma...@ibatis.apache.org>>
>>>
>>>
>>>
>>>
>>>    --    Guy Rouillier
>>>
>>>
>>>    ---------------------------------------------------------------------
>>>    To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>>    <ma...@ibatis.apache.org>
>>>    For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>    <ma...@ibatis.apache.org>
>>>
>>>
>>>
>>
>> --
>> Guy Rouillier
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: two parametr in Mapper method

Posted by Clinton Begin <cl...@gmail.com>.
multiple parameters will require the XML equivalent parameter type to be
Map.  Behind the scenes, it will do exactly what you do today -- wrap
multiple params in a Map.  This keeps it simple and consistent.
Clinton

On Mon, Oct 5, 2009 at 12:23 AM, Guy Rouillier <gu...@burntmail.com>wrote:

> I'm glad to see you are considering allowing multiple parameters.  I've
> found having to bind everything into one is cumbersome.
>
> What are you thinking of doing for XML?  I'd suggest replacing
> ParameterType with ParameterList, with the latter a cut and paste from the
> mapper method.  Your example below would look like:
>
> parameterList="int offset, int limit"
>
> From a programmer's perspective, I'd find the cut and paste easy, and
> iBatis would have everything it needs to enable named parameters in the SQL.
>
> Clinton Begin wrote:
>
>> There's no way to introspect on the parameter names.
>> So your choices become:
>>
>> @Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
>> List getAllItems(int offset, int limit);
>>
>> ...Or...
>>
>> @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>> List getAllItems(@Param("offset") int offset, @Param("limit") int limit);
>>
>> Both suck. But we'll probably default to the first, and allow for the
>> second.
>> Gross.
>>
>> Clinton
>>
>> On Sun, Oct 4, 2009 at 8:00 PM, Guy Rouillier <guyr-ml1@burntmail.com<mailto:
>> guyr-ml1@burntmail.com>> wrote:
>>
>>    I'd be curious to understand what the Java limitation is.  I would
>>    have thought that with Java 1.5's support of varargs, limitations
>>    such as this would no longer exists.  Of course, to use varargs
>>    here, I suppose we'd have to use Object[], which would shoot your
>>    type safety.
>>
>>    Clinton Begin wrote:
>>
>>        It's a limitation in Java.  However, we are working on a couple
>>        of potential options.  But it's not possible to do it the way
>>        you've written it (which is really sad, because it's perfectly
>>        possible in C# and other languages).
>>
>>        Clinton
>>
>>        2009/10/4 Tomáš Procházka <t.prochazka@centrum.cz
>>        <ma...@centrum.cz> <mailto:t.prochazka@centrum.cz
>>        <ma...@centrum.cz>>>
>>
>>
>>
>>           Why not supported this?
>>
>>           @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>>            List getAllItems(int offset, int limit);
>>
>>
>>           Its limitation of Java or bug in actual version?
>>
>>
>> ---------------------------------------------------------------------
>>           To unsubscribe, e-mail:
>>        user-java-unsubscribe@ibatis.apacheorg
>>        <ma...@ibatis.apache.org>
>>           <mailto:user-java-unsubscribe@ibatis.apache.org
>>        <ma...@ibatis.apache.org>>
>>
>>           For additional commands, e-mail:
>>        user-java-help@ibatis.apache.org
>>        <ma...@ibatis.apache.org>
>>           <mailto:user-java-help@ibatis.apache.org
>>        <ma...@ibatis.apache.org>>
>>
>>
>>
>>
>>    --    Guy Rouillier
>>
>>
>>    ---------------------------------------------------------------------
>>    To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>    <ma...@ibatis.apache.org>
>>    For additional commands, e-mail: user-java-help@ibatis.apache.org
>>    <ma...@ibatis.apache.org>
>>
>>
>>
>
> --
> Guy Rouillier
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: two parametr in Mapper method

Posted by Guy Rouillier <gu...@burntmail.com>.
I'm glad to see you are considering allowing multiple parameters.  I've 
found having to bind everything into one is cumbersome.

What are you thinking of doing for XML?  I'd suggest replacing 
ParameterType with ParameterList, with the latter a cut and paste from 
the mapper method.  Your example below would look like:

parameterList="int offset, int limit"

 From a programmer's perspective, I'd find the cut and paste easy, and 
iBatis would have everything it needs to enable named parameters in the SQL.

Clinton Begin wrote:
> There's no way to introspect on the parameter names.  
> 
> So your choices become:
> 
> @Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
> List getAllItems(int offset, int limit);
> 
> ...Or...
> 
> @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
> List getAllItems(@Param("offset") int offset, @Param("limit") int limit);
> 
> Both suck. But we'll probably default to the first, and allow for the 
> second.  
> 
> Gross.
> 
> Clinton
> 
> On Sun, Oct 4, 2009 at 8:00 PM, Guy Rouillier <guyr-ml1@burntmail.com 
> <ma...@burntmail.com>> wrote:
> 
>     I'd be curious to understand what the Java limitation is.  I would
>     have thought that with Java 1.5's support of varargs, limitations
>     such as this would no longer exists.  Of course, to use varargs
>     here, I suppose we'd have to use Object[], which would shoot your
>     type safety.
> 
>     Clinton Begin wrote:
> 
>         It's a limitation in Java.  However, we are working on a couple
>         of potential options.  But it's not possible to do it the way
>         you've written it (which is really sad, because it's perfectly
>         possible in C# and other languages).
> 
>         Clinton
> 
>         2009/10/4 Tomáš Procházka <t.prochazka@centrum.cz
>         <ma...@centrum.cz> <mailto:t.prochazka@centrum.cz
>         <ma...@centrum.cz>>>
> 
> 
> 
>            Why not supported this?
> 
>            @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>             List getAllItems(int offset, int limit);
> 
> 
>            Its limitation of Java or bug in actual version?
> 
>            
>          
>          ---------------------------------------------------------------------
>            To unsubscribe, e-mail:
>         user-java-unsubscribe@ibatis.apacheorg
>         <ma...@ibatis.apache.org>
>            <mailto:user-java-unsubscribe@ibatis.apache.org
>         <ma...@ibatis.apache.org>>
> 
>            For additional commands, e-mail:
>         user-java-help@ibatis.apache.org
>         <ma...@ibatis.apache.org>
>            <mailto:user-java-help@ibatis.apache.org
>         <ma...@ibatis.apache.org>>
> 
> 
> 
> 
>     -- 
>     Guy Rouillier
> 
> 
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>     <ma...@ibatis.apache.org>
>     For additional commands, e-mail: user-java-help@ibatis.apache.org
>     <ma...@ibatis.apache.org>
> 
> 


-- 
Guy Rouillier

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: two parametr in Mapper method

Posted by Clinton Begin <cl...@gmail.com>.
There's no way to introspect on the parameter names.
So your choices become:

@Select({"SELECT * FROM send LIMIT #{1}, #{2}"})
List getAllItems(int offset, int limit);

...Or...

@Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
List getAllItems(@Param("offset") int offset, @Param("limit") int limit);

Both suck. But we'll probably default to the first, and allow for the
second.

Gross.

Clinton

On Sun, Oct 4, 2009 at 8:00 PM, Guy Rouillier <gu...@burntmail.com>wrote:

> I'd be curious to understand what the Java limitation is.  I would have
> thought that with Java 1.5's support of varargs, limitations such as this
> would no longer exists.  Of course, to use varargs here, I suppose we'd have
> to use Object[], which would shoot your type safety.
>
> Clinton Begin wrote:
>
>> It's a limitation in Java.  However, we are working on a couple of
>> potential options.  But it's not possible to do it the way you've written it
>> (which is really sad, because it's perfectly possible in C# and other
>> languages).
>>
>> Clinton
>>
>> 2009/10/4 Tomáš Procházka <t.prochazka@centrum.cz <mailto:
>> t.prochazka@centrum.cz>>
>>
>>
>>    Why not supported this?
>>
>>    @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>>     List getAllItems(int offset, int limit);
>>
>>
>>    Its limitation of Java or bug in actual version?
>>
>>
>>    ---------------------------------------------------------------------
>>    To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>    <ma...@ibatis.apache.org>
>>    For additional commands, e-mail: user-java-help@ibatis.apache.org
>>    <ma...@ibatis.apache.org>
>>
>>
>>
>
> --
> Guy Rouillier
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: two parametr in Mapper method

Posted by Guy Rouillier <gu...@burntmail.com>.
I'd be curious to understand what the Java limitation is.  I would have 
thought that with Java 1.5's support of varargs, limitations such as 
this would no longer exists.  Of course, to use varargs here, I suppose 
we'd have to use Object[], which would shoot your type safety.

Clinton Begin wrote:
> It's a limitation in Java.  However, we are working on a couple of 
> potential options.  But it's not possible to do it the way you've 
> written it (which is really sad, because it's perfectly possible in C# 
> and other languages).
> 
> Clinton
> 
> 2009/10/4 Tomáš Procházka <t.prochazka@centrum.cz 
> <ma...@centrum.cz>>
> 
> 
>     Why not supported this?
> 
>     @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>      List getAllItems(int offset, int limit);
> 
> 
>     Its limitation of Java or bug in actual version?
> 
>      
> 
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>     <ma...@ibatis.apache.org>
>     For additional commands, e-mail: user-java-help@ibatis.apache.org
>     <ma...@ibatis.apache.org>
> 
> 


-- 
Guy Rouillier

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: two parametr in Mapper method

Posted by Clinton Begin <cl...@gmail.com>.
It's a limitation in Java.  However, we are working on a couple of potential
options.  But it's not possible to do it the way you've written it (which is
really sad, because it's perfectly possible in C# and other languages).
Clinton

2009/10/4 Tomáš Procházka <t....@centrum.cz>

>
> Why not supported this?
>
> @Select({"SELECT * FROM send LIMIT #{offset}, #{limit}"})
>  List getAllItems(int offset, int limit);
>
>
> Its limitation of Java or bug in actual version?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>