Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 9431 invoked from network); 9 Jan 2007 12:57:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Jan 2007 12:57:32 -0000 Received: (qmail 50664 invoked by uid 500); 9 Jan 2007 12:57:36 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 50590 invoked by uid 500); 9 Jan 2007 12:57:36 -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 50579 invoked by uid 99); 9 Jan 2007 12:57:36 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jan 2007 04:57:36 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of larry.meadors@gmail.com designates 64.233.184.224 as permitted sender) Received: from [64.233.184.224] (HELO wr-out-0506.google.com) (64.233.184.224) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jan 2007 04:57:27 -0800 Received: by wr-out-0506.google.com with SMTP id i7so2773462wra for ; Tue, 09 Jan 2007 04:57:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=EAMpCHw0+MfzopJzSrauM4CGUt7MPQxW4PwNznOJnMqu1OLEteh0JHxnpMtrYqzoyAktNUtX3r66uaQAZYmtzYAog571OdC21EEaAQjBRj5PwNblianN9hyQ+hgt5mxwumM1ngcaJQYACcjCdSCAEkdmgVkxrMQhWIa/AE8ZAAg= Received: by 10.90.98.10 with SMTP id v10mr2832708agb.1168347426797; Tue, 09 Jan 2007 04:57:06 -0800 (PST) Received: by 10.90.35.5 with HTTP; Tue, 9 Jan 2007 04:57:06 -0800 (PST) Message-ID: Date: Tue, 9 Jan 2007 05:57:06 -0700 From: "Larry Meadors" Reply-To: lmeadors@apache.org Sender: larry.meadors@gmail.com To: user-java@ibatis.apache.org, pbenedict@apache.org Subject: Re: Can ibatis work with java object with constructor have parameters? In-Reply-To: <45A33C97.7070700@apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <2fe5ef5b0701071741i60367027i9718cb4a089c4677@mail.gmail.com> <299154da0701071826m414c4c67m4118936fe57752a@mail.gmail.com> <567624C728CF6544ADFCB285B34D5B931897CF@ms07.mse2.exchange.ms> <2fe5ef5b0701072015s60ecf227r7bf521aa35356e87@mail.gmail.com> <2fe5ef5b0701072045j10b88395j69f76fe2348f2b97@mail.gmail.com> <45A33C97.7070700@apache.org> X-Google-Sender-Auth: ba16be4225746cf0 X-Virus-Checked: Checked by ClamAV on apache.org Hey Paul, If all you want is the SQL, you can get that with a tiny bit of hacking: === Reader reader; SqlMapClientImpl smc; SelectStatement statement; String sql; // this is just plumbing: reader = Resources.getResourceAsReader("com/mwt/config/sqlmap.xml"); smc = (SqlMapClientImpl) SqlMapClientBuilder.buildSqlMapClient(reader); // At this point, you can get a statement and get freaky with it // ...all unsupported of course, and if a later release breaks it, you // have been warned. :-) statement = (SelectStatement) smc.getDelegate().getMappedStatement("Customers.fetch"); // replace the 2nd parameter below with YOUR parameter object, a bean or map or whatever. sql = statement.getSql().getSql(null, null); // ALSO, who says this has to be SQL? it could be HQL, or an LDAP query, or // whatever other crazy stuff you want to try. This is the result in any case: System.out.println(sql); === Larry On 1/8/07, Paul Benedict wrote: > Brandon, > > Sometimes it's good to construct the object directly with access to the > ResultSet, but using IBATIS to dynamically write the SQL. There's a > ticket open for this functionality: > > http://issues.apache.org/jira/browse/IBATIS-226 > > My driver is because I cache at the object instance level, and return > the same instance for the same primary key. This is a little deeper than > ibatis' caching which is at the statement level -- but with multiple > statements potentially returning the same object (in terms of object > identity), this is where having access to the ResultSet is necessary. If > I can shortcut the creation of the object, I will. > > Paul > > Brandon Goodin wrote: > > I'm not completely sure what you are asking. But, if you are asking if > > you can get the ResultSet itself that would be a no. iBATIS is JDBC > > wrapper. If you find that you need more direct access to JDBC then you > > should use JDBC directly. > > > > Brandon > > > > On 1/7/07, *Carfield Yim* > > wrote: > > > > Can I get the reference of resultset when the object is initalizating? > > > > On 1/8/07, Brandon Goodin > > wrote: > > > You can find the javadoc here: > > > > > > > > http://ibatis.apache.org/docs/java/dev/com/ibatis/sqlmap/engine/mapping/result/ResultObjectFactory.html > > > > > > > > I was assuming you were wanting to map result values to a > > constructor. If > > > you are trying to map results to a constructor, it would seem a > > tedious > > > effort to use the ResultObjectFactory for this. > > > > > > I know it is lame that we don't have this functionality. But, we've > > > discussed adding the constructor mapping functionality and have > > decided it > > > is best to delay adding it until iB3 (no eta). > > > > > > Brandon > > > > > > > > > On 1/7/07, Carfield Yim > > wrote: > > > > I just check for the document and I cannot see those APIs , > > > > http://ibatis.apache.org/docs/java/user/ , am I looking > > > for wrong > > > > thing? > > > > > > > > On 1/8/07, Goga, Murtaza < murtaza.goga@trisyngroup.com > > > wrote: > > > > > Have you considered using an implementation of > > ResultObjectFactory? It > > > can be configured within iBatis or injected into the > > SqlMapExecutorDelegate. > > > Either ways you will have control over the creation and subsequent > > > initialization of objects. > > > > > > > > > > ________________________________ > > > > > > > > > > From: Peng Wang [mailto: wpcfan@gmail.com > > ] > > > > > Sent: Sun 1/7/2007 9:26 PM > > > > > To: user-java@ibatis.apache.org > > > > > > > Subject: Re: Can ibatis work with java object with > > constructor have > > > parameters? > > > > > > > > > > > > > > > You can do this using Spring. I think iBatis does not have to > > support > > > this. > > > > > > > > > > > > > > > On 1/8/07, Carfield Yim < carfield@gmail.com > > > wrote: > > > > > > > > > > To bad to hear that, is it planned to be implemented? > > > > > > > > > > On 1/8/07, Brandon Goodin < brandon.goodin@gmail.com > > > wrote: > > > > > > This is not currently implemented. > > > > > > > > > > > > Brandon > > > > > > > > > > > > > > > > > > On 1/6/07, Carfield Yim < carfield@gmail.com > > > > > > > wrote: > > > > > > > I like to pass something to the object while > > initalization, > > > can I > > > > > > > specific about that? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >