Return-Path: X-Original-To: apmail-cayenne-dev-archive@www.apache.org Delivered-To: apmail-cayenne-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C349E17251 for ; Sat, 31 Jan 2015 15:11:37 +0000 (UTC) Received: (qmail 36266 invoked by uid 500); 31 Jan 2015 15:11:38 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 36235 invoked by uid 500); 31 Jan 2015 15:11:38 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 36223 invoked by uid 99); 31 Jan 2015 15:11:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Jan 2015 15:11:37 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: local policy) Received: from [202.161.115.54] (HELO fish.ish.com.au) (202.161.115.54) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Jan 2015 15:11:32 +0000 Received: from ip-211.ish.com.au ([203.29.62.211]:18694 helo=ish.com.au) by fish.ish.com.au with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1YHZex-0008Hl-21 for dev@cayenne.apache.org; Sun, 01 Feb 2015 02:08:32 +1100 Received: from [10.242.2.6] (HELO Aristedess-MacBook-Pro.local) by ish.com.au (CommuniGate Pro SMTP 6.1c1) with ESMTPS id 17976746 for dev@cayenne.apache.org; Sun, 01 Feb 2015 02:08:31 +1100 Message-ID: <54CCEFEE.2060607@maniatis.org> Date: Sun, 01 Feb 2015 02:08:30 +1100 From: Aristedes Maniatis User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:34.0) Gecko/20100101 Thunderbird/34.0 MIME-Version: 1.0 To: dev@cayenne.apache.org Subject: Re: SQLExec query References: <94CB7084-FF82-4404-B62B-FADBDA4F7B59@objectstyle.org> <54C58DC1.8080701@maniatis.org> <54C6D131.10104@maniatis.org> <54C837C1.3080504@maniatis.org> <6263CBBB-F975-4354-B4BE-C4D92BFF3C11@objectstyle.org> In-Reply-To: <6263CBBB-F975-4354-B4BE-C4D92BFF3C11@objectstyle.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Can you give an example of the type of multi-part query you have in mind and how the code would be used. Ari On 31/01/2015 11:38pm, Andrus Adamchik wrote: > "execute" will only be used when a query is known or expected to be "multi-part" (my own term), i.e. returns more than one ResultSet, performs more than one update (or a combination of selects or updates). There are more meaningful shortcuts for single-result queries. If you expect a single ResultSet, you use SQLSelect.select(..), for a single insert/update, you use SQLExec.update(..). This roughly mirrors the types of results a JDBC Statement can return: > > ResultSet executeQuery(..) > int executeUpdate(..) > int[] executeBatch(..) > boolean execute(..) // this one is multi-part > > Andrus > > >> On Jan 27, 2015, at 8:13 PM, Aristedes Maniatis wrote: >> >> On 27/01/2015 10:45pm, Andrus Adamchik wrote: >>> List is a confusing data structure. When iterating through it you will need to do instanceof/cast on every entry, and more importantly, you will need to know upfront what are the valid entries in there. >>> >>> With List you don't do instanceof/cast, and also if say tomorrow we add/change something in the entry format/type, we simply alter QueryResult API, making the change visible to the user. >> >> OK, so let's examine your example: >> >> List result = SQLExec >> .query("INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME) VALUES (#bind($id), #bind($name))") >> .paramsArray(55, "a3") >> .execute(context); >> >> Let's say I want to get the number of rows added. I do this: >> >> count = result.get(0).getBatchUpdateResult()[0]; or >> count = result.get(0).getUpdateResult(); >> >> except that I didn't run an "UPDATE", I ran an "INSERT". But perhaps that can be solved with enough javadocs to explain the naming... >> >> >> Now, for a result set: >> >> List result = SQLExec.query("CALL getContacts_proc()").execute(context); >> >> List contact = (List) result.get(0).getSelectResult(); >> >> >> >> Am I missing the point here? >> >> >> Ari >> >> >> >> -- >> --------------------------> >> Aristedes Maniatis >> GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A >> > -- --------------------------> Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A