openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "roger.keays" <roger.ke...@ninthavenue.com.au>
Subject 1.1.0-SNAPSHOT: broken query in eager loaded relation
Date Tue, 20 May 2008 01:43:54 GMT

Hi All,

Here is a query which works fine in OpenJPA 1.0.2:

query = em.createQuery("SELECT item FROM Content item WHERE " +
                "item.url=:url AND item.root.uuid=:id")
        .setParameter("url", url)
        .setParameter("id", id);

but in 1.1.0-SNAPSHOT the following exception is thrown:

<openjpa-1.1.0-SNAPSHOT-r422266:657918 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: ERROR: missing
FROM-clause entry for table "t0" {prepstmnt 1036977 SELECT t0.content,
t2.ITEM_UUID, t2.id, t2.inheritable, t2.level, t2.role, t2.type, t2.username
FROM CMS_CONTENT t1 LEFT OUTER JOIN CMS_PRIVILEGES t2 ON t1.uuid =
t2.ITEM_UUID WHERE t0.uuid = ? ORDER BY t2.ITEM_UUID ASC [params=(long) 4]}
[code=0, state=42P01]
	org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)

org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)
	org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
	org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
	org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)

org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:526)

org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
	org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)

org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2911)
	org.apache.openjpa.kernel.StateManagerImpl.load(StateManagerImpl.java:376)
	org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:862)
	org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:774)

org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:811)
	org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:258)

org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2228)

org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.loadEagerJoin(RelationFieldStrategy.java:510)

org.apache.openjpa.jdbc.meta.FieldMapping.loadEagerJoin(FieldMapping.java:790)

org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:860)

org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:841)

org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:820)

org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:342)

org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:263)

org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)

org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
	org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:894)
	org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)
	org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:774)

org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:811)
	org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:258)

org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2228)
	org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:252)

org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
	org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:36)
	org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1222)
	org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:989)
	org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:847)
	org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:778)
	org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:525)
	org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:237)
	org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:277)
	au.com.ninthavenue.cms.application.CMS.getItem(CMS.java:218)


I think the query should probably look something like this:

SELECT t2.ITEM_UUID, t2.id, t2.inheritable, t2.level, t2.role, t2.type,
t2.username FROM CMS_CONTENT t1 LEFT OUTER JOIN CMS_PRIVILEGES t2 ON t1.uuid
= t2.ITEM_UUID WHERE t1.uuid = ? ORDER BY t2.ITEM_UUID ASC [params=(long) 4]

Can't see where the t0.content field comes from (?). The CMS_PRIVILEGES
table is for an eager loaded list of Privilege entities. If I change it to
lazy loaded, the problem disappears.

Cheers,

Roger
-- 
View this message in context: http://www.nabble.com/1.1.0-SNAPSHOT%3A-broken-query-in-eager-loaded-relation-tp17331680p17331680.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


Mime
View raw message