Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 11638 invoked from network); 12 Dec 2007 08:03:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Dec 2007 08:03:16 -0000 Received: (qmail 90997 invoked by uid 500); 12 Dec 2007 08:03:04 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 90976 invoked by uid 500); 12 Dec 2007 08:03:04 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 90965 invoked by uid 99); 12 Dec 2007 08:03:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Dec 2007 00:03:04 -0800 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Dec 2007 08:03:06 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1J2MYH-0006gz-U4 for users@openjpa.apache.org; Wed, 12 Dec 2007 00:02:45 -0800 Message-ID: <14290536.post@talk.nabble.com> Date: Wed, 12 Dec 2007 00:02:45 -0800 (PST) From: "roger.keays" To: users@openjpa.apache.org Subject: Re: WHERE clauses with ORDER BY subclass field In-Reply-To: <14290053.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: roger.keays@ninthavenue.com.au References: <14290053.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org roger.keays wrote: > > I've noticed that in 1.0.0, 1.0.1 and 1.1.0-SNAPSHOT I cannot combine > WHERE and ORDER BY if they both use subclass fields. This wasn't a problem > in 0.9.7 Correction: this hasn't changed since 0.9.7. The problem has appeared since I switched from using mapping files to annotations. Perhaps somebody here could have a look at how I am bootstrapping the EMF. The regular methods using persistence.xml aren't flexible enough for us, so we do it programatically using the following code: PersistenceUnitInfoImpl pui = new PersistenceUnitInfoImpl(); Boolean hasEntities = false; if (mappingFiles != null) { for (String mapping : mappingFiles) { pui.addMappingFileName(mapping); hasEntities = true; } } if (entities != null) { for (String entity : entities) { pui.addManagedClassName(entity); hasEntities = true; } } if (hasEntities) { PersistenceProductDerivation pd = new PersistenceProductDerivation(); try { ConfigurationProvider cp = pd.load(pui, allConfig); BrokerFactory factory = Bootstrap.newBrokerFactory(cp, pui.getClassLoader()); site.setEmf(JPAFacadeHelper.toEntityManagerFactory(factory)); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } } Could this be causing the problem? It seems strange that it works using mapping files, but not when we provide a list of annotated entity class names. Thanks in advance, Roger > e.g. these queries work (id is a subclass field, uuid is a superclass > field): > > SELECT i FROM News i ORDER BY i.id; > SELECT i FROM News i WHERE i.id > 1; > SELECT i FROM News i WHERE i.uuid > 1 ORDER BY i.uuid; > SELECT i FROM News i WHERE i.id > 1 ORDER BY i.uuid; > SELECT i FROM News i WHERE i.uuid > 1 ORDER BY i.id; > > but this query fails: > > SELECT i FROM News i WHERE i.id > 1 ORDER BY i.id; > > the stack trace follows. > > Caused by: > org.apache.openjpa.persistence.Persiste > nceException: ERROR: missing FROM-clause entry for table "t0" {prepstmnt > 26955692 SELECT t1.uuid, t2.id, > t2.comment, t2.inheritable, t2.level, t2.role, t2.type, t2.username FROM > FB_METADATA t1 INNER JOIN FB_P > RIVILEGES t2 ON t1.uuid = t2.item_uuid WHERE (t0.id > ?) ORDER BY t1.uuid > ASC [params=(long) 1]} [code=0 > , state=42P01] > at > org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:3849) > at > org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:97) > at > org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:83) > at > org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:59) > at > org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.handleCheckedException(SelectResult > ObjectProvider.java:155) > at > org.apache.openjpa.datacache.QueryCacheStoreQuery$CachingResultObjectProvider.handleCheckedEx > ception(QueryCacheStoreQuery.java:634) > at > org.apache.openjpa.lib.rop.EagerResultList.(EagerResultList.java:40) > at > org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1223) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:799) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:769) > at > org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:533) > at > org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:235) > at > org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:277) > at furnace.core.el.EntityFunctions.query1(EntityFunctions.java:71) > > t0 should be FB_NEWS > -- View this message in context: http://www.nabble.com/WHERE-clauses-with-ORDER-BY-subclass-field-tp14290053p14290536.html Sent from the OpenJPA Users mailing list archive at Nabble.com.