Issue #2583: Using SELECT BETWEEN with LocalDate

Type: BugVersion: 2.8.3_01Priority: NormalStatus: FixedReplies: 2
#1

I am trying to query all entities whose date is between today and today + X days.

The date inside the entity is a LocalDate.

To do so I created the following query:

.createQuery(
  "SELECT e FROM Element e WHERE e.date between CURRENT_DATE and :date",
  Element.class)
.setParameter("date", date)
.getResultList();

I get the following error for e.date in IntelliJ (Type mismatch: number, date or string expected) but in the thread of https://www.objectdb.com/issue/2564 it is said that inside the SELECT a Date is used and not a LocalDate, so I ignored this error.

Now I tried a LocalDate, a java.sql.Data and a java.util.Data as the "date" parameter but for all three tries I get the following exception:

com.objectdb.o._PersistenceException: Operand type mismatch for operator 'between'
    at com.objectdb.o._PersistenceException.a(_PersistenceException.java:45) ~[objectdb-2.8.3_01.jar:na]
    at com.objectdb.o.JPE.d(JPE.java:147) ~[objectdb-2.8.3_01.jar:na]
    at com.objectdb.o.ERR.h(ERR.java:56) ~[objectdb-2.8.3_01.jar:na]
    at com.objectdb.o.OBC.onObjectDBError(OBC.java:1588) ~[objectdb-2.8.3_01.jar:na]
    at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:733) ~[objectdb-2.8.3_01.jar:na]

Is this a bug or am I doing something terribly wrong?

 

Thanks and regards

#2

Thank you for this report. This may be related to the new (and not complete yet) support of local dates. We will look into it and update.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

Thank you again for this report. It was indeed a new issue with local dates and BETWEEN.

Please try the fix of build 2.8.3_02.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login