ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Poitras Christian <Christian.Poit...@ircm.qc.ca>
Subject RE: Parameters in Mapper class methods?
Date Wed, 18 Nov 2009 14:43:15 GMT
You need to add a @Param annotation to your parameters.

    public interface UserMapper {
        List<UserDto> selectPage(@Param("start") int start, @Param("limit") int limit,
@Param("sortFieldName") String sortFieldName, @Param("sortDirection") String sortDirection);

Christian

________________________________
From: Stephen Friedrich [mailto:stephen.friedrich@fortis-it.eu]
Sent: Wednesday, November 18, 2009 9:40 AM
To: user-java@ibatis.apache.org
Subject: Parameters in Mapper class methods?

I can't make much sense of the documentation as it is very sparse on this topic and always
mixes different styles of querying.

So: I have this code snippet, that works fine, using XML only:

        Map params = new HashMap();
        params.put("start", start);
        params.put("limit", limit);
        params.put("sortFieldName", sortFieldName);
        params.put("sortDirection", sortDirection);
        List<UserDto> users = sqlSession.selectList("com.acme.foo.mapper.UserMapper.selectPage",
params);

Now I tried to use this mapper class instead, to get cleaner code:

    public interface UserMapper {
        List<UserDto> selectPage(int start, int limit, String sortFieldName, String
sortDirection);

Is that supposed to work?
All I get is an SQL exception telling me that the statement is not terminated properly.


Mime
View raw message