On Wed, Apr 29, 2009 at 4:58 PM, Jason King <jhk...@airmail.net> wrote: > Is there some reason you can't use the dynamic where clause feature in > iBatis. > > This is an example stolen directly from Clinton's book. > > <select id="getChildCategories" parameterClass="Category" > > resultClass="Category"> > > SELECT * > > FROM category > > <dynamic prepend="WHERE "> > > <isNull property="parentCategoryId"> > > parentCategoryId IS NULL > > </isNull> > > <isNotNull property="parentCategoryId"> > > parentCategoryId=#parentCategoryId# > > </isNotNull> > > </dynamic> > > </select> > > Doing dynamic wheres is more wordy than $-style replacement, but it does > allow binds.
This would mean that we have to add _all_ possible filters to each query where we want filtering, including options like BETWEEN, LIKE, <=, >=, ==, IS NULL, IS NOT NULL etc etc. Yes it's possible, but it's not a workable solution, since we have many different filters and they differ per query we want to do filtering on. The idea is that we can filter results on most of the fields in that result, with different filter types depending on the data type of the field. So with dates you get a between option, with strings you get the LIKE option. And we want to do this in the database and not in the front end, for performance reasons.