Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AF6F2EA97 for ; Tue, 28 May 2013 14:36:07 +0000 (UTC) Received: (qmail 88376 invoked by uid 500); 28 May 2013 14:36:07 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 88286 invoked by uid 500); 28 May 2013 14:36:07 -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 88260 invoked by uid 99); 28 May 2013 14:36:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 14:36:06 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of giulio.cesare@gmail.com designates 209.85.214.44 as permitted sender) Received: from [209.85.214.44] (HELO mail-bk0-f44.google.com) (209.85.214.44) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 14:36:00 +0000 Received: by mail-bk0-f44.google.com with SMTP id jc3so4281259bkc.17 for ; Tue, 28 May 2013 07:35:40 -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; bh=OzvOlA++Mx78jqeDRpPl0FKWRTs7Z6eFY0GA4aAuxvw=; b=qAiDGpqFGgicK9FlyVwCI5b4HXYBQ43smIVSIK0qi82sIrXpzxXrgzFivfvl8QLhpQ fek8Sx2zYQVF5lK81BBy+MyagYfLVmkS38kPeV4+uJ2GpbKDtdGl2unPk0sJ5NuCXRcl P2fz3SkoMfKXYB7DQEZYyZ1/CMp+d064ORBmgoAEhz0v/2oDRiN9Aga6v4jas1EJI7s4 4wqDikqzWTydRfX7uFoXuxjcJWZl5y3b+VVTjS7xnInYxmJg8tQ46+oRcgwinhkTg+6L 1HugEGGMmdIoxbPch5V9J/xiZQvjQlzT2QLEDiORaWmiLfWGmsIiJJ7q6XvTQ/kiRjWG okbQ== MIME-Version: 1.0 X-Received: by 10.205.38.195 with SMTP id tj3mr13440550bkb.67.1369751739907; Tue, 28 May 2013 07:35:39 -0700 (PDT) Received: by 10.204.16.85 with HTTP; Tue, 28 May 2013 07:35:39 -0700 (PDT) In-Reply-To: References: <13085.105.249.62.7.1369748538.squirrel@webmail.xsinet.co.za> Date: Tue, 28 May 2013 16:35:39 +0200 Message-ID: Subject: Re: SQLTemplate returning NULL results From: "giulio.cesare@gmail.com" To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=bcaec52bf14be3743304ddc82d72 X-Virus-Checked: Checked by ClamAV on apache.org --bcaec52bf14be3743304ddc82d72 Content-Type: text/plain; charset=UTF-8 Hello Andrus, I have dug through the code, and I have found a point where something I don't understand happens. When `SQLTemplateMetadata.resolve` method is invoked, `query.result()` return null, and this means that `resultSetMapping` is set to null. But the query is actually returning three results; it looks like SQLTemplateMetadata is accessing query.result before the query is actually executed. Does this analysis make any sense? Regards, Giulio Cesare On Tue, May 28, 2013 at 4:22 PM, giulio.cesare@gmail.com < giulio.cesare@gmail.com> wrote: > Jurgen, > > thanks for the tip; but I am either completely blind (as I can see no > differences in the query compared to the structure of the DB), or there is > something else going on in my case. > > As stated in the initial message, I have also tried using the same exact > SQL statement logged by Cayenne when using SelectQuery instead of > SQLTemplate; but to no avail. > > I will post here any findings. > > Giulio Cesare > > > > On Tue, May 28, 2013 at 3:42 PM, wrote: > >> Hi Giulio, >> >> I've had this problem before. Try the following: goto SaleSummary in >> Cayenne Modeler and click on the attributes tab. >> >> Make sure that your SQLTemplate query contains all the DbAttributes >> listed. >> They must be spelt exactly the same way (CaPs SenSitiTive), order isn't >> important. >> >> Also the table's Primary key MUST be included as indicated in the related >> table/view dbEntity for SaleSummary. Also CaPs SenSitiTive ! >> >> Hope this helps >> regards >> Jurgen >> >> >> > Hello everybody, >> > >> > I am getting lost in trying to use an SQLTemplate query. >> > >> > I have tried to reduce the problem to the core, and this is the point >> > where >> > I am stuck. >> > >> > The following two lines of code do what I was expecting them to do: >> > Query query = new SelectQuery(SaleSummary.class); >> > List saleSummariesToProcess = >> > objectContext.performQuery(query); >> > >> > Looking into the logs, this is the SQL statement generated automatically >> > by >> > Cayenne: >> >> SELECT t0.amount, t0.unique_id, t0.period, t0.registrationDate, >> >> t0.id_contract, t0.id_currency, t0.id_customer, t0.id_frontendSystem, >> >> t0.id_saleSummary, t0.id_store FROM wolf.SaleSummary t0 >> > >> > So far, so good. But as soon as I replace the SelectQuery with a >> > SQLTemplate, I can no longer get any result. Actually, I get the >> expected >> > results, but instead of being instances of SaleSummary, the list >> contains >> > all nulls. >> > >> > I need to run a fairly complex query that I would like to store into the >> > model, but also the most trivial tests are failing. >> > >> > I have tried all the following options, all with the same bad result: >> > - query = new SQLTemplate(SaleSummary.class, "select * from >> salesummary"); >> > - query = new SQLTemplate(SaleSummary.class, "SELECT * FROM >> SALESUMMARY"); >> > - query = new SQLTemplate(SaleSummary.class, "SELECT t0.amount, >> > t0.unique_id, t0.period, t0.registrationDate, t0.id_contract, >> > t0.id_currency, t0.id_customer, t0.id_frontendSystem, t0.id_saleSummary, >> > t0.id_store FROM wolf.SaleSummary t0"); >> > >> > This latest option includes the same exact SQL query logged by the >> initial >> > working code (that was using the SelectQuery class instead of >> > SQLTemplate). >> > >> > Am I doing something blatantly wrong, or is there something weird going >> on >> > here? >> > >> > BTW, I am using Cayenne 3.1B2. I was tempted to go back to 3.0.2, but >> > being >> > the model files not compatible, I was trying to understand why it is not >> > working on 3.1B2 first. >> > >> > Any hints? >> > >> > Best regards, >> > >> > Giulio Cesare >> > >> >> >> > --bcaec52bf14be3743304ddc82d72--