ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Pita <carlosjosep...@gmail.com>
Subject Re: Unconstrained signature interface mappers for ibatis 3
Date Mon, 31 Aug 2009 05:14:10 GMT
> @Select("select * from employee where first_name = #{firstName} and
> last_name = #{lastName})
> List<Employee> findEmployeesLike(@Param("firstName") String firstName,
> @Param("lastName") String lastName, Constraint offsetLimit);

Clinton, after considering all of your insightful remarks altogether
I've come to the conclusion that the above option is ok, because:

1) I don't care about exposing Constraint (or ResultHandler) to upper
layers anymore. It's fine for me.

2) Now I'm not thinking in terms of full-fledged daos (although I must
say after your last post that my concept of dao was far simpler than
yours from the very beginning, not so distant from your beloved
mappers at all), so I don't expect full interface flexibility, no
matter what this thread's subject still asks for :).

3) Although redundant and repetitive, @Param anotations will be a very
convenient shortcut for the alternative procedures of

i. building a map: cumbersome, not type-safe thus goes against the
purpose of mapper interfaces.

ii. creating simple dtos for the mere purpose of passing parameters:
type-safe but yet more cumbersome.

Of course, for the usual single parameter signature, annotation will
be optional (or even forbidden).

Consider the difference:

i) using a map:

List<User> findCommonFriends(Map<String, User> userPair);

Map<String,User> userPair = new HashMap<String,User>();
userPair.put("user1", user1);
userPair.put("user2", user2);

ii)  using a dto:

class UserPair {

   private final User user1;
   private final User user2;

   public UserPair(User user1, User user2) {
      this.user1 = user1;
      this.user2 = user2;

   public User getUser1() {
     return user1;

   public User getUser2() {
     return user2;
List<User> findCommonFriends(UserPair userPair);

iii) using annotations

List<User> findCommonFriends(@Param("user1") User user1,
@Param("user2") User user2);

Of course there are a number of tricks than can be done to alleviate
the exuberance of (i) and (ii)
to a certain extent, but not even remotely close to (iii) briefness.

Have we a deal ;) ?

Best regards

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

View raw message