db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Watzek <mwa.t...@spree.de>
Subject SQL queries with candidate classes
Date Thu, 10 Nov 2005 17:43:09 GMT
Hi Andy, Erik,

I'm currently testing SQL queries with candidate classes. I run into 
exceptions and like to make sure that the tests are alright.

The first SQL query selects all columns from table PrimitiveTypes:

     Query query = pm.newQuery("javax.jdo.query.SQL", "SELECT * FROM 
PrimitiveTypes");
     query.setClass(PrimitiveTypes.class);
     query.execute()

Query execution throws an NPE thrown in JPOX code using application 
identity (see below). Query execution succeeds using datastore identity.

The second SQL query selects two columns from table departments:

     Query query = pm.newQuery("javax.jdo.query.SQL", "SELECT id, name 
FROM departments");
     query.setClass(Department.class);
     query.execute()

Query execution throws a JDOFatalUserException using both identity types 
(see below). It seems that JPOX tries to instantiate relationship field 
"employees".

Are both queries valid?

Regards,
Michael

java.lang.NullPointerException
     [java]      at 
org.jpox.store.mapping.SingleFieldMapping.getObject(SingleFieldMapping.java:296)
     [java]      at 
org.jpox.store.rdbms.fieldmanager.ResultSetGetter.fetchObjectField(ResultSetGetter.java:101)
     [java]      at 
org.jpox.state.StateManagerImpl.replacingObjectField(StateManagerImpl.java:2642)
     [java]      at 
org.apache.jdo.tck.pc.mylib.PrimitiveTypes.jdoReplaceField(PrimitiveTypes.java)
     [java]      at 
org.apache.jdo.tck.pc.mylib.PrimitiveTypes.jdoReplaceFields(PrimitiveTypes.java)
     [java]      at 
org.jpox.state.StateManagerImpl.replaceFields(StateManagerImpl.java:2822)
     [java]      at 
org.jpox.store.query.PersistentIDROF$1.fetchFields(PersistentIDROF.java:236)
     [java]      at 
org.jpox.state.StateManagerImpl.<init>(StateManagerImpl.java:424)
     [java]      at 
org.jpox.AbstractPersistenceManager.getObjectByAID(AbstractPersistenceManager.java:2254)
     [java]      at 
org.jpox.store.query.PersistentIDROF.getObjectByAID(PersistentIDROF.java:231)
     [java]      at 
org.jpox.store.query.PersistentIDROF.getObject(PersistentIDROF.java:182)
     [java]      at 
org.jpox.store.query.ForwardQueryResult.nextResultSetElement(ForwardQueryResult.java:103)
     [java]      at 
org.jpox.store.query.ForwardQueryResult.advanceToEndOfResultSet(ForwardQueryResult.java:93)
     [java]      at 
org.jpox.store.query.ForwardQueryResult.size(ForwardQueryResult.java:356)
     [java]      at 
org.apache.jdo.tck.query.QueryTest.equalsCollection(QueryTest.java:478)
     [java]      at 
org.apache.jdo.tck.query.QueryTest.checkQueryResultWithoutOrder(QueryTest.java:406)
     [java]      at 
org.apache.jdo.tck.query.QueryTest.execute(QueryTest.java:898)
     [java]      at 
org.apache.jdo.tck.query.sql.AllowedAPIMethods.testSetClass(AllowedAPIMethods.java:95)
     [java]      at 
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
     [java]      at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]      at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:204)
     [java]      at 
org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:120)
     [java]      at 
org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:95)





javax.jdo.JDOFatalUserException: Mapping 
org.jpox.store.mapping.CollectionMapping@1ef4b not suitable for a SQL 
result column, field = employees
     [java]      at 
org.jpox.store.query.SQLQuery.performExecute(SQLQuery.java:295)
     [java]      at 
org.jpox.store.query.Query.executeWithMap(Query.java:931)
     [java]      at 
org.jpox.store.query.SQLQuery.executeWithArray(SQLQuery.java:186)
     [java]      at org.jpox.store.query.Query.execute(Query.java:833)
     [java]      at 
org.apache.jdo.tck.query.QueryTest.execute(QueryTest.java:884)
     [java]      at 
org.apache.jdo.tck.query.sql.AllowedAPIMethods.testSetClass(AllowedAPIMethods.java:95)
     [java]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
     [java]      at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]      at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:204)
     [java]      at 
org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:120)
     [java]      at 
org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:95)
-- 
-------------------------------------------------------------------
Michael Watzek                  Tech@Spree Engineering GmbH
mailto:mwa.tech@spree.de        Buelowstr. 66
Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
Fax.:  ++49/30/217 520 12       http://www.spree.de/
-------------------------------------------------------------------

Mime
View raw message