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 90199DBC6 for ; Tue, 28 May 2013 07:24:42 +0000 (UTC) Received: (qmail 85208 invoked by uid 500); 28 May 2013 07:24:41 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 85026 invoked by uid 500); 28 May 2013 07:24:38 -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 84691 invoked by uid 99); 28 May 2013 07:24:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 07:24:34 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 28 May 2013 07:24:28 +0000 Received: (qmail 5831 invoked from network); 28 May 2013 07:27:05 -0000 Received: from unknown (HELO ?192.168.1.20?) (212.98.191.213) by vorsha.objectstyle.org with SMTP; 28 May 2013 07:27:05 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: Re: SQLTemplate returning NULL results From: Andrus Adamchik In-Reply-To: Date: Tue, 28 May 2013 10:24:06 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <341F71D9-10BE-4297-9520-109FF974A430@objectstyle.org> References: To: user@cayenne.apache.org X-Mailer: Apple Mail (2.1503) X-Virus-Checked: Checked by ClamAV on apache.org I think I've seen it before. This could the column naming in the result = set not exactly matching DbEntity. Try this maybe:=20 query.setColumnNamesCapitalization(CapsStrategy.LOWER); And yes, we need to improve this in Cayenne - instead of NULLs we prolly = need to throw an Exception or something. Andrus On May 28, 2013, at 9:52 AM, giulio.cesare@gmail.com wrote: > Hello everybody, >=20 > I am getting lost in trying to use an SQLTemplate query. >=20 > I have tried to reduce the problem to the core, and this is the point = where > I am stuck. >=20 > The following two lines of code do what I was expecting them to do: > Query query =3D new SelectQuery(SaleSummary.class); > List saleSummariesToProcess =3D > objectContext.performQuery(query); >=20 > 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 >=20 > 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. >=20 > 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. >=20 > I have tried all the following options, all with the same bad result: > - query =3D new SQLTemplate(SaleSummary.class, "select * from = salesummary"); > - query =3D new SQLTemplate(SaleSummary.class, "SELECT * FROM = SALESUMMARY"); > - query =3D 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"); >=20 > This latest option includes the same exact SQL query logged by the = initial > working code (that was using the SelectQuery class instead of = SQLTemplate). >=20 > Am I doing something blatantly wrong, or is there something weird = going on > here? >=20 > 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. >=20 > Any hints? >=20 > Best regards, >=20 > Giulio Cesare