Search code examples
javajdodatanucleus

Cannot perform operation ".isEmpty" on org.datanucleus.store.rdbms.sql.expression.SubqueryExpression


I have a subquery that looks like this: (It was rewrited from contains, because of perfomance issues)

...(select from RecoLock lock where mpiSubscriptionId == this.mpiSubscriptionId).isEmpty())

And datanucleus throws me a


Cannot perform operation ".isEmpty" on org.datanucleus.store.rdbms.sql.expression.SubqueryExpression


But in datanucleus documentation there are examples where similiar code workds well. What am I doing wrong?

datanucleus version is 4.1.0


Solution

  • From what I see of the DataNucleus JDOQL support for {subquery}.isEmpty() this is only supported from v5.0.

    If using v4.x (or earlier) you can transform your query to do

    ... (select COUNT(lock) from RecoLock lock where mpiSubscriptionId == this.mpiSubscriptionId) == 0)
    

    which should equate to the same thing as "size == 0" (i.e "empty")