DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCJODATIME-4
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Unassigned
Reporter: Victor Ott
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
DataNucleus Types : JodaTime

JodaTime field to value comparisons not possible with operators less-than, greater-than, etc

Created: 02/Jul/10 12:30 AM   Updated: 06/Jun/12 12:28 PM   Resolved: 06/Jun/12 12:27 PM
Component/s: None
Affects Version/s: 2.1.0.release
Fix Version/s: None

Environment: JDK 6, JodaTime 1.6, Windows XP

Datastore: PostgreSQL
Severity: Production


 Description  « Hide
_startDate is a Joda "DateTime" field mapped to a timestamp column. Following JDOQL should work:
        "_startDate >= :startDateMin"
where "startDateMin" parameter is also DateTime.

The result is:
org.datanucleus.store.rdbms.sql.expression.IllegalExpressionOperationException: Cannot perform operation ">=" on org.datanucleus.store.rdbms.sql.expression.TemporalExpression@93466e and org.datanucleus.store.rdbms.sql.expression.JodaDateTimeLiteral@f4e114

Stack trace is attached below. Similar error occurs for the other operators too: <, >, etc.


With datanucleus-jodatime-2.0.2 I had to use following workaround:
   parameterValues.add(minDate.toDate());
but this fails with datanucleus-jodatime-2.1.0 issuing following error (which imho makes sense):

org.datanucleus.exceptions.NucleusUserException: Parameter "0" was specified as java.util.Date but should have been org.joda.time.DateTime


Here the stack trace:

Caused by: org.datanucleus.store.rdbms.sql.expression.IllegalExpressionOperationException: Cannot perform operation ">=" on org.datanucleus.store.rdbms.sql.expression.TemporalExpression@93466e and org.datanucleus.store.rdbms.sql.expression.JodaDateTimeLiteral@f4e114
at org.datanucleus.store.rdbms.sql.expression.SQLExpression.ge(SQLExpression.java:431) ~[datanucleus-rdbms-2.1.1.jar:na]
at org.datanucleus.store.rdbms.sql.expression.TemporalExpression.ge(TemporalExpression.java:170) ~[datanucleus-rdbms-2.1.1.jar:na]
at org.datanucleus.store.rdbms.sql.expression.DelegatedExpression.ge(DelegatedExpression.java:82) ~[datanucleus-rdbms-2.1.1.jar:na]
at org.datanucleus.store.rdbms.query.QueryToSQLMapper.processGteqExpression(QueryToSQLMapper.java:1583) ~[datanucleus-rdbms-2.1.1.jar:na]
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileRelationalExpression(AbstractExpressionEvaluator.java:89) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileOrAndExpression(AbstractExpressionEvaluator.java:65) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.evaluate(AbstractExpressionEvaluator.java:46) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.query.expression.Expression.evaluate(Expression.java:334) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.query.expression.DyadicExpression.evaluate(DyadicExpression.java:73) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.query.expression.DyadicExpression.evaluate(DyadicExpression.java:67) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.query.expression.DyadicExpression.evaluate(DyadicExpression.java:67) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.query.expression.DyadicExpression.evaluate(DyadicExpression.java:67) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.store.rdbms.query.QueryToSQLMapper.compileFilter(QueryToSQLMapper.java:423) ~[datanucleus-rdbms-2.1.1.jar:na]
at org.datanucleus.store.rdbms.query.QueryToSQLMapper.compile(QueryToSQLMapper.java:343) ~[datanucleus-rdbms-2.1.1.jar:na]
at org.datanucleus.store.rdbms.query.JDOQLQuery.compileQueryFull(JDOQLQuery.java:814) ~[datanucleus-rdbms-2.1.1.jar:na]
at org.datanucleus.store.rdbms.query.JDOQLQuery.compileInternal(JDOQLQuery.java:296) ~[datanucleus-rdbms-2.1.1.jar:na]
at org.datanucleus.store.query.Query.executeQuery(Query.java:1643) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.store.query.Query.executeWithArray(Query.java:1514) ~[datanucleus-core-2.1.1.jar:na]
at org.datanucleus.jdo.JDOQuery.executeWithArray(JDOQuery.java:312) ~[datanucleus-core-2.1.1.jar:na]



Andy Jefferson added a comment - 02/Jul/10 08:41 AM
Testcase ?

Andy Jefferson made changes - 02/Jul/10 08:41 AM
Field Original Value New Value
Priority Critical [ 2 ] Major [ 3 ]
Andy Jefferson added a comment - 06/Jun/12 12:27 PM
Well I can't see this error, and we have a test that does what you implied. See SVN trunk under tests/accessplatform/trunk/test.jdo.general/src/test/org/datanucleus/tests/types/JodaTimeTest

Andy Jefferson made changes - 06/Jun/12 12:27 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Cannot Reproduce [ 5 ]
Andy Jefferson made changes - 06/Jun/12 12:28 PM
Status Resolved [ 5 ] Closed [ 6 ]