ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gwyn Evans" <gwyn.ev...@gmail.com>
Subject Re: Problem with sql statement, help wanted.
Date Mon, 23 Jun 2008 19:42:43 GMT
You've got 'dynamic' SQL for the "${schema1}" part, but for changing the
values in the select queries, you just need the normal ibatis usage, i.e.

    ...between #startYear# and #endYear# and office = #office#

Note: This assumes that your parameterClass class (model.AccountExample) has
either bean properties or accessors for the '#' values, e.g. a 'startYear'
field or a 'getStartYear()' method, etc...

See also http://cwiki.apache.org/WICKET/ibatis.html for an example...

/Gwyn

On Mon, Jun 23, 2008 at 5:44 PM, Sophia <jdev02@telenet.be> wrote:

> Would anyone help me.
>
> When I use this:
>
> List tmpList = accountList2Dao.selectByAccountList2(account2Example);
>
> And this in my sqlmap:
>
> <select id="selectByAccountList2" parameterClass="model.AccountExample"
> resultMap="abatorgenerated_AccountResult">
>    Select number, etc……… from ${schema1}.account where number in
>    (select number from ${schema1}.account where substr(number,5,4) between
> '2002' and '2006' and office = 'L2')
>  </select>
>
> I get al the data that I want, and it works fine.
> The problem is that the sql is dynamic, I mean that the data 2002 – 2006
> and L2 is inputted by the user thru a webpage.
> When I rewrite in the past my application to Ibatis I have no problem with
> any select, insert, delete statement (Abator)
> But when I now want to write my own specific sql, it will not work.
>
> Now, my problem is when I use this :
>
> account2Example.createCriteria().andNumberDateBetween(startdate,
> enddate).andOfficeEqualTo(office);
>
> and this as sql
>
> <select id="selectByAccountList2" parameterClass="model.AccountExample"
> resultMap="abatorgenerated_AccountResult">
>    Select number, etc……… from ${schema1}.account where number in
>    (select number from ${schema1}.account )
>  </select>
>
> I get errors, can anyone tell me a easy way to write your own sql
> statements in Ibatis?
> Help and suggestions are appreciated.
>
>
> Regards,
> Sophia.
>
>
>
>

Mime
View raw message