Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 89EC3200D0A for ; Wed, 4 Oct 2017 14:43:50 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 885321609E2; Wed, 4 Oct 2017 12:43:50 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C77DA1609D6 for ; Wed, 4 Oct 2017 14:43:49 +0200 (CEST) Received: (qmail 30256 invoked by uid 500); 4 Oct 2017 12:43:49 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 30236 invoked by uid 99); 4 Oct 2017 12:43:48 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Oct 2017 12:43:48 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D8032180EF3 for ; Wed, 4 Oct 2017 12:43:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.648 X-Spam-Level: X-Spam-Status: No, score=-1.648 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, RCVD_IN_SORBS_SPAM=0.5, SPF_NEUTRAL=0.652] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=objectstyle-com.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id GuV9u5DX1ZhT for ; Wed, 4 Oct 2017 12:43:45 +0000 (UTC) Received: from mail-io0-f181.google.com (mail-io0-f181.google.com [209.85.223.181]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 949BD5FBEE for ; Wed, 4 Oct 2017 12:43:45 +0000 (UTC) Received: by mail-io0-f181.google.com with SMTP id q11so10380960ioe.10 for ; Wed, 04 Oct 2017 05:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=objectstyle-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=FDXE+Tys73uBOfHuW6sfd6+HbFAb3eXbE7i9TTYjDSo=; b=pE6NziqBPiM5Ygx5+4JgSmHHMSBB1SZkNw0Hq1yECuVgXhwCKoTF9fwSxoHdQ44XwZ 15T9meDfGTCp7NV/5CA9wTbFrnvlc08G1FMg5HMoWRpcRfUrj9HsIlJ3TqCAsE8rOGJX EQBZoCVK2JRjpEEEc946s1dnaCg1paiAB632rn5OoU3BkHYTsrP6KdcGLeeFJuav+Kka qOIKVQ+6Cw66K+WgW3NplsHTkZnUiqYUXmzdusC7m19NXrq69SxD6TquEzzSNUs4n1c0 TU1Ctr+jzQryPR/CNeQb+hcyEW3ydra16sSvERMyeOv6nhfglZWu7pu1/poTYw2lDB0c ezCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=FDXE+Tys73uBOfHuW6sfd6+HbFAb3eXbE7i9TTYjDSo=; b=XDW0VtAOMzx477Udflrw+o/4IKxabOuLRIXeirf+pb6kTRyQ3utL3ddZLsYwVWpl6d cH/aK5/uCtYlEjHUtDS5YqNIbVy8mMoIxQpyaLmB2jBojFc01m2iQzbP6y3xa//7HeC3 Acxg76UNlufTAEK5CDKLwE9qK0GirAMn31lWSLacg7gFE8NpU2b1ygwLzPygYh8n2bv7 lv9eeVA7eyKrruGEfkpPMlwKYmFLyEuygMxtqwWg/ENRLfA8J3Wt9bAHrbofrp1HVaIJ C+Zm/oGSx2/GzN8wGsy/HEeib3L2/saCR1/HPyYT9QqAkabHS4BiGUQbMfzrNhoJKRL4 xYMg== X-Gm-Message-State: AHPjjUjIEP1hsVBdKk++0Rxwx78QEiMZ55e/WHCHfxNoqwuBNJTWBtyX 2myyodT7mMUwhtvb5KCdditUsHF30mjFvKLCnx32K7b1 X-Google-Smtp-Source: AOwi7QAZoq+tX/HabsTnSvQlAEc37ohINeu73dH5vzgVaqbes7W4dnkS4RLy7PbN010G01s1X9k8Bj1tXcXxntCI/gw= X-Received: by 10.107.47.220 with SMTP id v89mr33134847iov.299.1507121024766; Wed, 04 Oct 2017 05:43:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.42.196 with HTTP; Wed, 4 Oct 2017 05:43:24 -0700 (PDT) In-Reply-To: References: From: Nikita Timofeev Date: Wed, 4 Oct 2017 15:43:24 +0300 Message-ID: Subject: Re: ObjectSelect.columnQuery To: Apache Cayenne Content-Type: text/plain; charset="UTF-8" archived-at: Wed, 04 Oct 2017 12:43:50 -0000 Yes you can add this property: Property property3 = Property.createSelf(Cargo.class); But this will eagerly fetch all content of Cargo. On Wed, Oct 4, 2017 at 3:30 PM, ab@dataloy.com wrote: > > > On 2017-10-04 13:57, Nikita Timofeev wrote: >> ObjectSelect.columnQuery can select individual columns, as it was >> designed just for that. >> However you can also use it to get full entities along with some >> arbitrary properties (aggregates, dependent objects, etc.). >> In your case you created property with type of "Cargo" and it returns >> you collection of Cargo objects. >> Just use correct type of required column (String, Integer, etc.). >> >> However easiest (and also safe) way to use it is via static Properties >> generated in a superclass of your entity, i.e. something like this: >> >> List someStringProperties = >> ObjectSelect.columnQuery(Cargo.class, >> Cargo.SOME_STRING_PROPERTY).select(ctx); >> >> >> On Wed, Oct 4, 2017 at 12:45 PM, ab@dataloy.com wrote: >> > Should ObjectSelect.columnQuery execute a SQL query with just one column selected? >> > >> > I am using Cayenne 4.1 but running this code: >> > >> > Property property1 = Property.create("area", Cargo.class); >> > >> > List select = ObjectSelect.columnQuery(Cargo.class,property1).where(Expression.fromString("area>10")).select(ctx); >> > >> > the query executed select all the columns of cargo table. >> > >> > I need to specify which columns the queries must return because I have tables with hundreds of columns that I do not need, returning all the columns every time is very time consuming. >> > >> > Andrea >> >> >> >> -- >> Best regards, >> Nikita Timofeev > But if I do something like this: > > Property property1 = Property.create("area", String.class); > Property property2 = Property.create("voyage.flCost", Double.class); > List select = ObjectSelect.query(Cargo.class).columns(property1,property2).select(ctx); > > There is the possibility to get a list of Cargo objects? -- Best regards, Nikita Timofeev