Issue Details (XML | Word | Printable)

Key: JDO-174
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: AJSoft
Reporter: Michael Watzek
Votes: 0
Watchers: 0
Operations

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

JPOX fails on a query comparing the result of Map.get with an expression.

Created: 07/Oct/05 12:46 AM   Updated: 25/Oct/05 01:21 AM
Return to search
Component/s: tck2
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Resolution Date: 25/Oct/05 01:21 AM


 Description  « Hide
JPOX fails on a query comparing the result of Map.get with an expression. This bug may be reproduced applying patch JDO-159. The following query fails throwing an exception:

SELECT FROM org.apache.jdo.tck.pc.company.Person WHERE phoneNumbers.get('home') == '1111'

org.jpox.store.expression.ScalarExpression$IllegalOperationException: Cannot perform operation "==" on ObjectExpression "THIS_PHONENUMBERS.PHONENO" and StringLiteral "'1111'"
at org.jpox.store.expression.ScalarExpression.eq(ScalarExpression.java:325)
at org.jpox.store.expression.ObjectExpression.eq(ObjectExpression.java:228)
at org.jpox.store.query.JDOQLQuery$Compiler.compileEqualityExpression(JDOQLQuery.java:1105)
at org.jpox.store.query.JDOQLQuery$Compiler.compileAndExpression(JDOQLQuery.java:1087)
at org.jpox.store.query.JDOQLQuery$Compiler.compileExclusiveOrExpression(JDOQLQuery.java:1075)
at org.jpox.store.query.JDOQLQuery$Compiler.compileInclusiveOrExpression(JDOQLQuery.java:1063)
at org.jpox.store.query.JDOQLQuery$Compiler.compileConditionalAndExpression(JDOQLQuery.java:1051)
at org.jpox.store.query.JDOQLQuery$Compiler.compileConditionalOrExpression(JDOQLQuery.java:1033)
at org.jpox.store.query.JDOQLQuery$Compiler.compileExpression(JDOQLQuery.java:1010)
at org.jpox.store.query.JDOQLQuery$Compiler.compileQueryStatement(JDOQLQuery.java:888)
at org.jpox.store.query.JDOQLQuery.compile(JDOQLQuery.java:566)
at org.jpox.store.query.JDOQLQuery.performExecute(JDOQLQuery.java:636)
at org.jpox.store.query.Query.executeWithMap(Query.java:891)
at org.jpox.store.query.Query.executeWithArray(Query.java:871)
at org.jpox.store.query.Query.execute(Query.java:803)
at org.apache.jdo.tck.query.QueryTest.execute(QueryTest.java:639)
at org.apache.jdo.tck.query.QueryTest.executeAPIQuery(QueryTest.java:559)
at org.apache.jdo.tck.query.QueryTest.executeAPIQuery(QueryTest.java:535)
at org.apache.jdo.tck.query.jdoql.methods.SupportedMapMethods.executeQuery(SupportedMapMethods.java:142)
at org.apache.jdo.tck.query.jdoql.methods.SupportedMapMethods.testGet(SupportedMapMethods.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:204)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:120)
at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:95)


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Michael Watzek added a comment - 17/Oct/05 05:44 PM
Component set to tck20.

Erik Bengtson added a comment - 17/Oct/05 05:52 PM
Should you cast in the get return?

((String)phoneNumbers.get('home')) == '1111'

Craig Russell added a comment - 18/Oct/05 03:07 AM
The information needed by the implementation is in the metadata for the class. I think the implementation should be able to do the cast itself based on the metadata, which in this case identifies the value-type (the return type of "get") as a String.

I could look at adding some more detail in the specification if you think it is useful, but the intent of the metadata is to allow specifying as much detail as is known about the types of the persistent fields.

I would agree with Erik if the value-type were not specific enough (for example, if the value-type were a superclass and the expression needed a subclass type).

        <class name="Person"
            identity-type="application"
            objectid-class="org.apache.jdo.tck.pc.company.Person$Oid">
            <field name="personid" primary-key="true"/>
            <field name="middlename" default-fetch-group="false"/>
            <field name="address"
                   persistence-modifier="persistent"/>
<field name="phoneNumbers" persistence-modifier="persistent">
                <map key-type="String" value-type="String"/>
            </field>
        </class>

Erik Bengtson added a comment - 18/Oct/05 03:31 AM
Right, I forgot about this detail. We will cast it to the metadata type

Andy Jefferson added a comment - 25/Oct/05 01:21 AM
Fixed in JPOX CVS