ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DelGurth <delgu...@gmail.com>
Subject Re: Using #PARAM# constructions within $DYNAMICSQL$
Date Wed, 29 Apr 2009 16:54:22 GMT
On Wed, Apr 29, 2009 at 4:58 PM, Jason King <jhking@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.

Mime
View raw message