Java Mailing List Archive

Home » user-java.ibatis »

Advance Warning: API Change in iBATIS 3 Beta 4

Clinton Begin


Replies: Find Java Web Hosting

Author LoginPost Reply
Hi all,

As with any major release, once it's in the wild, we find things that we'd like to change.  Rather than live with something we're not happy with for the next few years, we've decided to make a couple of simple API changes to clean a few things up.


  List selectList(String statement, Object parameter, RowBounds rowBounds)
  void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler)

These methods used to take two int params to define the OFFSET and LIMIT for limiting the rows that were returned (for paging etc).  We've introduced the RowBounds class to clean that up, but also to allow for multi-parameter bindings.  So that this is now possible in Mapper classes:

  List<Post> findAllPostsLike(@Param("subject") String subject, @Param("body") String body, RowBounds rowBounds);

RowBounds can be any parameter, not necessarily the last one.  You don't have to specify @Param, as it will default to using the ordinal position e.g. #{1} #{2}, but with the @Param annotations, you can use #{subject} and #{body}.  If you only specify a single parameter, then it's passed as always, as the top level parameter (with all properties accessible by name without qualification).

Also, I've moved ALL classes that SqlSession and SqlSessionFactory depend upon, into the .session package.  Therefore you don't have to import so many packages, and the classes will be easier to find if you're looking for them (balancing practicality with practice).  The affected classes include: Configuration, ResultHandler, RowBounds, ExecutorType, and ResultContext.

I think these changes were worth it, despite the slight annoyance.  Any modern IDE will have this fixed up for you in minutes.


©2008 - Jax Systems, LLC, U.S.A.