You need to: Add your query to the sqlMap file. Add a new method to your DAO (and DAO interface if you have one) that calls the new query. Change your code to call your new method instead.
I tend to start off by copying and renaming the (i)aBator selectByPrimaryKey in the SQlMap and edit the query (and the parameterClass if needed). --- On Thu, 19/6/08, Sophia <[EMAIL PROTECTED]> wrote: > From: Sophia <[EMAIL PROTECTED]> > Subject: RE: Problem with my query. > To: user-java@ibatis.apache.org > Date: Thursday, 19 June, 2008, 6:03 PM > Yes, that is what I meant. > Someone have any ideas how to start? > It would appreciate if someone gives me some tips. > > Regards > Sophia > > > > -----Original Message----- > From: Jeff Butler [mailto:[EMAIL PROTECTED] > Sent: donderdag 19 juni 2008 16:48 > To: user-java@ibatis.apache.org > Subject: Re: Problem with my query. > > I think you mean that you don't know how to build this > query with > *ibator* generated objects. > > Ibator does not support this type of query - you will need > to hand > code the query (the best alternative), or do two different > queries > with the ibator objects. > > Jeff Butler > > On Thu, Jun 19, 2008 at 9:06 AM, Sophia > <[EMAIL PROTECTED]> wrote: > > Thanks for your repley, > > > > The problem is, I dont know how to build this query in > Ibatis. > > > > select * from ACCOUNT where NUMBER in > > (select NUMBER from ACCOUNT where substr(ACCOUNT,5,4) > between '2002' and > > '2006') > > > > This must be build in ibatis. The question is, i have > not yet build something like this with a "in" > statement as query. > > The query at the end of my previous message is just a > piece of it. > > I use DB2 as database. > > > > Regards, > > Sophia > > > > > >>----- Oorspronkelijk bericht ----- > >>Van: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > >>Verzonden: donderdag, juni 19, 2008 03:11 PM > >>Aan: user-java@ibatis.apache.org > >>Onderwerp: Re: Problem with my query. > >> > >>I'm not entirely sure what you're trying to > do, as that query at the end > >>of your message looks like a good solution to me. > It sounds like you are > >>trying to do something more complicated. Depending > on your DBMS, you can > >>try something like this: > >> > >>select ACCOUNT.* from ACCOUNT, > >> (select NUMBER from ACCOUNT where > substr(ACCOUNT, 5, 4) between > >>'2002' and '2006') NUM > >>where ACCOUNT.NUMBER = NUM.NUMBER > >> > >>I'm sure any number of people can give you any > number of ways to optimize > >>this. Is the error that you get coming from your > DBMS or ibatis? > >> > >>-David > >> > >> > >> > >>From: > >>"Sophia" <[EMAIL PROTECTED]> > >>To: > >>user-java@ibatis.apache.org > >>Date: > >>06/19/2008 08:55 AM > >>Subject: > >>Problem with my query. > >> > >> > >> > >>Hallo everyone, > >> > >>I have a problem with my query, can someone help me > further > >>This is the query that I want to use in ibatis. > >> > >>select * from ACCOUNT where NUMBER in > >>(select NUMBER from ACCOUNT where > substr(ACCOUNT,5,4) between '2002' and > >>'2006?) > >> > >> > >>This is my source: > >> > >> > >>try { > >>dao.ACCOUNTDAO accountList2Dao = > >>(dao.ACCOUNTDAO)DaoManagerRequester.getDaoManager().getDao(dao.ACCOUNTDAO.class); > >>model.ACCOUNTExample account2Example = new > model.accountExample(); > >> > >>List resultList6 = > accountList2Dao.selectByAccountList2(account2Example); > >>account2Example.createCriteria().andNumberDateBetween(startdate, > enddate); > >> > >>List resultList6 = > accountList2Dao.selectByAccountList2(account2Example); > >> > >>... > >> > >>} catch ... > >> > >> > >>This works, and it gives me this: > >> > >>select * from ACCOUNT where substr(ACCOUNT,5,4) > between '2002' and '2006' > >> > >> > >>Any suggestions? > >> > >> > >>Regards, > >>Sophia > >> > >> > >> > >> > >> > > > > > > __________________________________________________________ Sent from Yahoo! Mail. A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html