Simple test case for a supposed Datanucleus issue
Java
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
pom.xml

README.md

datanucleus-null-param-query

Simple test case for a supposed Datanucleus issue. See http://www.datanucleus.org/servlet/forum/viewthread_thread,7579

To showcase the issue, simply run mvn test

The failing test parses this JDOQL query:

SELECT FROM ch.thierry.datanucleus.Person WHERE pName == null || name == pName PARAMETERS java.lang.String pName

and generates the following (formatted) SQL for HSQLDB:

SELECT 
    'ch.thierry.datanucleus.Person' AS NUCLEUS_TYPE,
    A0.ID,
    A0.NAME,
    A0.PERSON_ID
FROM
    PERSON A0
WHERE
    (? = NULL) OR (A0.NAME = ?)

The passing test directly uses JDBC with the following SQL:

SELECT 
    'ch.thierry.datanucleus.Person' AS NUCLEUS_TYPE,
    A0.ID,
    A0.NAME,
    A0.PERSON_ID
FROM
    PERSON A0
WHERE
    (? IS NULL) OR (A0.NAME = ?)

(The difference is (? = NULL) vs (? IS NULL)