Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 9856 invoked from network); 13 Jan 2010 18:43:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Jan 2010 18:43:31 -0000 Received: (qmail 87873 invoked by uid 500); 13 Jan 2010 18:43:30 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 87845 invoked by uid 500); 13 Jan 2010 18:43:30 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 87837 invoked by uid 99); 13 Jan 2010 18:43:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2010 18:43:30 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of clinton.begin@gmail.com designates 209.85.221.201 as permitted sender) Received: from [209.85.221.201] (HELO mail-qy0-f201.google.com) (209.85.221.201) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2010 18:43:22 +0000 Received: by qyk39 with SMTP id 39so505517qyk.27 for ; Wed, 13 Jan 2010 10:43:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=FqsBs9IhE+TTU3VIKc4VWCicDHRMdjV8t1scweofJWA=; b=HMbHY38+zCG/VXe2I8NQPQKtiR4Cc4vIjbq98v5HzwT2ImAeiiyt42aeCfmfSorDeT JkoQ84lE55DvcnpyEcDY3XEbt3SrMdang/PfQXo6VA4u6sKy6JrBy2TVw07x3E+6zckU qGdYhvtqGeuYsblSk1CCso6kOM63+vpnJQEes= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=tScL7ZRda6tsxBC4JJBdND7GBHQR7GMmH2ZP4QhQj3NJDwCutZg0+JeJgLGJ71b+mM YxD/JS/Tz/84x0dMZyD5/XX+pv8PFlzV23gWpj9tyaa21wKcTYQUeaPogRH7xIyEZOGd fBphvFnx+AXltIsFUB/tCFY4iDjyKl+wPc7TE= MIME-Version: 1.0 Received: by 10.224.78.23 with SMTP id i23mr6050046qak.321.1263408173000; Wed, 13 Jan 2010 10:42:53 -0800 (PST) In-Reply-To: <27148804.post@talk.nabble.com> References: <27148804.post@talk.nabble.com> Date: Wed, 13 Jan 2010 11:42:52 -0700 Message-ID: <16178eb11001131042p26ad6ea7h56f37045816841ee@mail.gmail.com> Subject: Re: How to use @SelectProvider From: Clinton Begin To: user-java@ibatis.apache.org Content-Type: multipart/alternative; boundary=00c09f9725055e0b3d047d1023b6 --00c09f9725055e0b3d047d1023b6 Content-Type: text/plain; charset=ISO-8859-1 @SelectProvider should be applied to your Mapper interface. For example: public interface MyMapper { @Select("SELECT * FROM users") User selectUsers(); } The SelectProvider equivalent of this would be: public interface MyMapper { @SelectProvider(type=com.me.SomeHelperClass,method="getSelectAllUsersSQL") User selectUsers(); } public clas SomeHelperClass { public String getSelectAllUsersSQL() { return "SELECT * FROM users"; } } Cheers, Clinton On Wed, Jan 13, 2010 at 11:37 AM, kruba02 wrote: > > Hi, > > I am trying to execute a dynamic/custom query using iBATIS (using > #SelectProvider) and am facing a couple of issues. > > 1. I have something like @SelectProvider(method = "selectTest", type = > "com.a.b.DynamicSQL") where method is the method-name and type is the name > of the class. I get an error here. Both the class and method exist. > selectTest looks like following. Any idea how I can remove the error? > > public String selectTest(){ > BEGIN(); > SELECT("*"); > FROM("test"); > return SQL(); > } > > 2. The documentation says that @SelectProvider is a method annotation. If I > annotate a method say Foo() using the above @SelectProvider, what should > the > method itself have? > > 3. Lastly, how do I invoke this select query? > > Your help is much appreciated. Sorry, I am just getting started with > iBATIS. > Also, are there any other ways to execute queries which are constructed on > the fly? > > Thanks in advance for your help. > KA > -- > View this message in context: > http://old.nabble.com/How-to-use-%40SelectProvider-tp27148804p27148804.html > Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org > For additional commands, e-mail: user-java-help@ibatis.apache.org > > --00c09f9725055e0b3d047d1023b6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable @SelectProvider should be applied to your Mapper interface.=A0 For example:=

public interface MyMapper {
=A0 @Select("SELECT * FROM user= s")
=A0 User selectUsers();
}

The SelectProvider equivale= nt of this would be:


public interface MyMapper {
=A0 @SelectProvider(type=3Dcom.me.SomeHelperClass,method=3D"getSelectA= llUsersSQL")
=A0 User selectUsers();
}

public clas SomeHelperClass {
=A0 public String getSelectAllUse= rsSQL() {
=A0 =A0 return "SELECT * FROM users";
=A0 }
}<= br>
Cheers,
Clinton



On Wed, Jan 13, 2010 at 11:37 AM, kr= uba02 <kruba02@ca.co= m> wrote:

Hi,

I am trying to execute a dynamic/custom query using iBATIS (using
#SelectProvider) and am facing a couple of issues.

1. I have something like @SelectProvider(method =3D "selectTest",= type =3D
"com.a.b.DynamicSQL") where method is the method-name and type is= the name
of the class. I get an error here. Both the class and method exist.
selectTest looks like following. Any idea how I can remove the error?

public String selectTest(){
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BEGIN();
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0SELECT("*");
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0FROM("test");
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return SQL();
=A0 =A0 =A0 =A0}

2. The documentation says that @SelectProvider is a method annotation. If I=
annotate a method say Foo() using the above @SelectProvider, what should th= e
method itself have?

3. Lastly, how do I invoke this select query?

Your help is much appreciated. Sorry, I am just getting started with iBATIS= .
Also, are there any other ways to execute queries which are constructed on<= br> the fly?

Thanks in advance for your help.
KA
--
View this message in context: http://old.nab= ble.com/How-to-use-%40SelectProvider-tp27148804p27148804.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


--00c09f9725055e0b3d047d1023b6--