Issue Details (XML | Word | Printable)

Key: NUCRDBMS-326
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Minor Minor
Assignee: Unassigned
Reporter: Leonard Broman
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

JDO operator "this" causes NullPointerException when querying nondurable entity

Created: 05/Mar/10 11:22 PM   Updated: 17/Mar/10 08:52 PM   Resolved: 06/Mar/10 08:51 AM
Component/s: Queries
Affects Version/s: 2.0.2
Fix Version/s: None

Environment: DataNucleus JDO 2.0.2 with DataNucleus rdbms 2.0.2 running as an Eclipse unit test onto HSQLDB with only generateSchema custom property set.

Datastore: HSQL


 Description  « Hide
When trying to query a non-durable entity using "this" operator in the filter, a NullPointerException is thrown when executing the query at:

java.lang.NullPointerException
at org.datanucleus.store.mapped.mapping.PersistableMapping.newScalarExpression(PersistableMapping.java:804)
at org.datanucleus.store.mapped.expression.LogicSetExpression.newFieldExpression(LogicSetExpression.java:136)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileIdentifier(JDOQLQueryCompiler.java:953)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compilePrimary(JDOQLQueryCompiler.java:774)
at org.datanucleus.store.rdbms.query.legacy.QueryCompiler.compileUnaryExpressionNotPlusMinus(QueryCompiler.java:1333)
at org.datanucleus.store.rdbms.query.legacy.QueryCompiler.compileUnaryExpression(QueryCompiler.java:1314)
at org.datanucleus.store.rdbms.query.legacy.QueryCompiler.compileMultiplicativeExpression(QueryCompiler.java:1267)
at org.datanucleus.store.rdbms.query.legacy.QueryCompiler.compileAdditiveExpression(QueryCompiler.java:1244)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileRelationalExpression(JDOQLQueryCompiler.java:687)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileEqualityExpression(JDOQLQueryCompiler.java:659)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileAndExpression(JDOQLQueryCompiler.java:647)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileExclusiveOrExpression(JDOQLQueryCompiler.java:635)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileInclusiveOrExpression(JDOQLQueryCompiler.java:623)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileConditionalAndExpression(JDOQLQueryCompiler.java:611)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileConditionalOrExpression(JDOQLQueryCompiler.java:593)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileExpression(JDOQLQueryCompiler.java:570)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compileExpressionFromString(JDOQLQueryCompiler.java:550)
at org.datanucleus.store.rdbms.query.legacy.QueryCompiler.compileFilter(QueryCompiler.java:852)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.performCompile(JDOQLQueryCompiler.java:261)
at org.datanucleus.store.rdbms.query.legacy.QueryCompiler.executionCompile(QueryCompiler.java:374)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQueryCompiler.compile(JDOQLQueryCompiler.java:225)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQuery.compileInternal(JDOQLQuery.java:175)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1628)
at org.datanucleus.store.rdbms.query.legacy.JDOQLQuery.executeQuery(JDOQLQuery.java:245)
at org.datanucleus.store.query.Query.executeWithArray(Query.java:1499)
at org.datanucleus.jdo.JDOQuery.execute(JDOQuery.java:243)
...

since "this" does not contain a AbstractMemberMetaData mmd.

Removing "this" and renaming the parameter works around the issue.

Query q = pm.newQuery(RoleValue.class);
q.setFilter("this.roleId == roleId");
q.declareParameters("Long roleId");
List<RoleValue> values = (List<RoleValue>) q.execute(2L);



@PersistenceCapable(table="jforum_role_values",identityType=IdentityType.NONDURABLE)
public class RoleValue {
    
    @Persistent(column="role_id")
    private Long roleId;
    
    @Persistent(column="role")
    private String value;

}

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 06/Mar/10 08:51 AM
Use JDOQL implementation "JDOQL2" (the one you're using is legacy and is not maintained). JDOQL2 will become the default before long. The SQL generated in JDOQL2 will be something like

SELECT 'org.datanucleus.test.Sample' AS NUCLEUS_TYPE,A0.ID,A0."VALUE"
FROM SAMPLE_TABLE A0 WHERE A0.ID = ?