Issue Details (XML | Word | Printable)

Key: JDO-321
Type: Test Test
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Erik Bengtson
Reporter: Michael Bouschen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JDO

JPOX throws exception for query with public static final field used without qualifying class name prefix

Created: 28/Feb/06 07:23 AM   Updated: 21/Mar/06 06:13 AM
Return to search
Component/s: tck2
Affects Version/s: JDO 2 rc1
Fix Version/s: JDO 2 final

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works JDO-321.patch 2006-03-03 06:19 AM Michael Bouschen 3 kB

Resolution Date: 21/Mar/06 06:13 AM


 Description  « Hide
I propose to add new test queries to query test class query.jdoql.IdentifiersEqualFieldNames accessing a public static final field declared in a company model class, e.g add the following constant to class Department:
  public static final int RECOMMENDED_NO_OF_EMPS = 2

This query works if the class name is used to qualify the static field name, e.g. Department.RECOMMENDED_NO_OF_EMPS


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig Russell added a comment - 28/Feb/06 08:34 AM
This seems like a good idea. Then we can test the field with a query, e.g. SELECT FROM Department WHERE emps.size() > RECOMMENDED_NO_OF_EMPS

Michael Bouschen added a comment - 03/Mar/06 06:19 AM
Attached you find aptach JDO-321.patch for review. It adds a public static final field to class Department and three new query test cases to class IdentifiersEqualFieldNames using the constant.

Please note, JPOX currently does not support using the public static final w/o class qualification:
  SELECT FROM org.apache.jdo.tck.pc.company.Department WHERE employees.size() > RECOMMENDED_NO_OF_EMPS
It runs into the following error:
1) testPositive(org.apache.jdo.tck.query.jdoql.IdentifiersEqualFieldNames)org.jpox.store.expression.ScalarExpression$IllegalOperationException: Cannot perform operation ">" on ContainerSizeExpression "(SELECT COUNT(*) FROM applicationidentity0.PERSONS THIS_EMPLOYEES WHERE THIS_EMPLOYEES.DEPARTMENT = THIS.ID)" and UnboundVariable

Craig Russell added a comment - 03/Mar/06 01:19 PM
Looks good.

Michael Bouschen added a comment - 05/Mar/06 05:07 AM
Checked in the patch adding new query tests accessing public static fields (see revision 383192).

Assigning the issue to Erik, because JPOX runs into a problem for a JDOQL query accessing a public static field w/o qualification:
  SELECT FROM org.apache.jdo.tck.pc.company.Department WHERE employees.size() > RECOMMENDED_NO_OF_EMPS
Here is the failure:
    [java] 1) testPositive(org.apache.jdo.tck.query.jdoql.IdentifiersEqualFieldNames)org.jpox.store.expression.ScalarExpression$IllegalOperationException: Cannot perform operation ">" on ContainerSizeExpression "(SELECT COUNT(*) FROM datastoreidentity0.PERSONS THIS_EMPLOYEES WHERE THIS_EMPLOYEES.DEPARTMENT = THIS.DATASTORE_IDENTITY)" and UnboundVariable
    [java] at org.jpox.store.expression.ScalarExpression.gt(ScalarExpression.java:518)
    [java] at org.jpox.store.expression.NumericExpression.gt(NumericExpression.java:175)
    [java] at org.jpox.store.expression.ContainerSizeExpression.gt(ContainerSizeExpression.java:62)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileRelationalExpression(JDOQLQuery.java:1571)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileEqualityExpression(JDOQLQuery.java:1525)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileAndExpression(JDOQLQuery.java:1513)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileExclusiveOrExpression(JDOQLQuery.java:1501)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileInclusiveOrExpression(JDOQLQuery.java:1489)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileConditionalAndExpression(JDOQLQuery.java:1477)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileConditionalOrExpression(JDOQLQuery.java:1459)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileExpression(JDOQLQuery.java:1436)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileExpressionFromString(JDOQLQuery.java:1397)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.compileFilter(JDOQLQuery.java:1236)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.performCompile(JDOQLQuery.java:846)
    [java] at org.jpox.store.query.JDOQLQuery$Compiler.executionCompile(JDOQLQuery.java:819)
    [java] at org.jpox.store.query.JDOQLQuery.performExecute(JDOQLQuery.java:447)
    [java] at org.jpox.store.query.Query.executeWithMap(Query.java:1113)
    [java] at org.jpox.store.query.Query.executeWithArray(Query.java:1086)
    [java] at org.jpox.store.query.Query.execute(Query.java:1009)
    [java] at org.apache.jdo.tck.query.QueryTest.execute(QueryTest.java:1192)
    [java] at org.apache.jdo.tck.query.QueryTest.execute(QueryTest.java:1070)
    [java] at org.apache.jdo.tck.query.QueryTest.executeAPIQuery(QueryTest.java:1007)
    [java] at org.apache.jdo.tck.query.QueryTest.executeAPIQuery(QueryTest.java:987)
    [java] at org.apache.jdo.tck.query.jdoql.IdentifiersEqualFieldNames.testPositive(IdentifiersEqualFieldNames.java:146)
    [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:205)
    [java] at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:120)
    [java] at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:95)

Erik Bengtson added a comment - 15/Mar/06 08:40 AM
fixed in JPOX CVS

Craig Russell added a comment - 21/Mar/06 06:13 AM
This is fixed with the latest JPOX SNAPSHOT.