As shown in JDOQL Reference DataNucleus supports queries using the JDOQL query language, using a Java-like syntax. When using JDOQL under RDBMS there are some specific situations where it can be useful to benefit from special treatment. These are listed here.

Use of contains() and variables

When using the method contains on a collection (or containsKey , containsValue on a map) this will either add an EXISTS subquery (if there is a NOT or OR present in the query) or will add an INNER JOIN across to the element table. Let's take an example

SELECT FROM org.datanucleus.samples.A
WHERE (elements.contains(b1) && b1.name == 'Jones')
VARIABLES org.datanucleus.samples.B b1

Note that we add the contains first that binds the variable "b1" to the element table, and then add the condition on the variable. The order is important here. If we instead had put the condition on the variable first we would have had to do a CROSS JOIN to the variable table and then try to repair the situation and change it to INNER JOIN if possible. In this case the generated SQL will be like

FROM `A` `A0`
WHERE `B0`.NAME = 'Jones'