Return-Path: X-Original-To: apmail-metamodel-dev-archive@minotaur.apache.org Delivered-To: apmail-metamodel-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 19E0F10F19 for ; Sat, 10 Aug 2013 16:40:04 +0000 (UTC) Received: (qmail 70208 invoked by uid 500); 10 Aug 2013 16:40:03 -0000 Delivered-To: apmail-metamodel-dev-archive@metamodel.apache.org Received: (qmail 70178 invoked by uid 500); 10 Aug 2013 16:40:03 -0000 Mailing-List: contact dev-help@metamodel.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@metamodel.incubator.apache.org Delivered-To: mailing list dev@metamodel.incubator.apache.org Received: (qmail 70170 invoked by uid 99); 10 Aug 2013 16:40:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Aug 2013 16:40:03 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of i.am.kasper.sorensen@gmail.com designates 209.85.212.182 as permitted sender) Received: from [209.85.212.182] (HELO mail-wi0-f182.google.com) (209.85.212.182) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Aug 2013 16:39:58 +0000 Received: by mail-wi0-f182.google.com with SMTP id hi8so598657wib.15 for ; Sat, 10 Aug 2013 09:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=Wv0B2YKx9btyEKKXWtdBHo6xDYiv78QQiTiUQkHJnwA=; b=fgs3bbXHn9E2PZOlk+DdoTUysoAcuKitQd+TIBB+T43P7owZH3LgvidIq7hGDaQdUg jiENPh68yhzlzNkiDEjv/H+DYoqtkuWs5ecanVx1FGo4azLU5ROsMFXH0ujf9ZIpzN+P W3JaK8Kx1g1CNkyfNrPU7DXXgFLUlvY9IWkDGxXAs10D0VUvE9Hik+G4+Ujva/lOfswr v52GMuPKV2cD4eXlntQqtOuQQIh37cX8ocJDiDxk3j7B8yzNrl/5e4e2IRtiXqgQCguf BxBccxUN2jxXwIfAxABLpifGbq4Y4PyyV/AUJBHUt+szje0djkmZWJVb6Aw0JbgzVAJ0 Csyw== MIME-Version: 1.0 X-Received: by 10.194.201.168 with SMTP id kb8mr3066142wjc.63.1376152776952; Sat, 10 Aug 2013 09:39:36 -0700 (PDT) Received: by 10.194.5.200 with HTTP; Sat, 10 Aug 2013 09:39:36 -0700 (PDT) In-Reply-To: References: Date: Sat, 10 Aug 2013 18:39:36 +0200 Message-ID: Subject: Re: [DISCUSS] get back update status after invoking executeUpdate(...) From: =?ISO-8859-1?Q?Kasper_S=F8rensen?= To: dev@metamodel.incubator.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org My experience with returning something like an int/String/other-simple-type is that it seems to fit the purpose at first, but then someone asks "couldn't we also get the status of [something], too?" ... and then you regret not encapsulating the return value so that you could just add another getter on it. 2013/8/10 Henry Saputra : > We could just make the executeUpdate just return number of elements > affected similar to relational databases. > > It would be simpler and serve similar purpose. > > - Henry > > > On Fri, Aug 9, 2013 at 12:15 AM, Kasper S=F8rensen < > i.am.kasper.sorensen@gmail.com> wrote: > >> Allow me to also bump this issue. >> >> Since this would be a change that would not be compile-time >> incompatible with previous versions, I suggest we introduce at least >> the return type of the method now. Since everyone moving the Apache >> MetaModel from the old metamodel would anyways have to recompile, they >> would not feel the runtime incompatibility of void vs. SomeReturnType. >> >> By now I suggest we just keep a very simple returned interface which >> we can always choose to expand (implemented internally, not by >> consumers). For instance something like: >> >> public interface UpdateStatus { >> public int getInsertedRows(); >> public int getUpdatedRows(); >> public int getDeletedRows(); >> } >> >> This should be quite easy to implement once and reuse for most of the >> modules. For some datastores it might not be information that we can >> retrieve, so the interface should also specify an extraordinary rule; >> e.g. "if -1 is returned it means that it is not known how many rows >> where inserted/updated/deleted" >> >> Kasper >> >> 2013/7/24 Kasper S=F8rensen : >> > In the current API design of MetaModel, the >> DataContext.executeUpdate(...) >> > method is a void method. This was initially chosen because not all >> > implementations have the capability to report anything about a particu= lar >> > update. But some do, for instance the no. of inserted, updated or dele= ted >> > records from a JDBC call. It would be nice to expose this information >> when >> > available. >> > >> > My suggestion for this would be to let the DataContext.executeUpdate(.= ..) >> > method return an object with this information. All methods on the new >> object >> > type would be optionally returning null, if no information is availabl= e. >> But >> > when available, we can at least expose it this way. >> > >> > The change wouldn't have a major impact, since any project using >> MetaModel >> > would already need to recompile because of the namespace change to >> > org.apache.metamodel. And the change would be compile-time compatible >> with >> > having a void return type. >>