I Found the problem.
It is the UNIQUE part of the query that causes jdoQuery.executeWithMap to 
return null. Removing the UNIQUE result in a DISTINCT in the generated query 
and the query returns a not null reference.
Gerrie
    On Sunday, 24 December 2017, 12:42:56 GMT+2, Gerrie Myburgh 
<[email protected]> wrote:  
 
 Hi,
I have written the following query : new javax.jdo.annotations.Query(
  name = "findByJobName",
  value = "SELECT UNIQUE "
    + "FROM domainapp.modules.system.dom.impl.PersonObject "
    + "WHERE tasks.contains(task) && task.parentJob.name == :name ")And it 
returns no records. This is correct as there is no data in the database, but 
when the query results are returned by getResults of 
PersistenceQueryFindUsingApplibQueryProcessor it returns null from the 
following code in the getResults method: try {
    final List<?> results = (List<?>) 
jdoQuery.executeWithMap(argumentsByParameterName);
    final List<?> resultsToReturn =
            cardinality == QueryCardinality.MULTIPLE
                    ? results
                    : results.isEmpty()
                        ? Collections.emptyList()
                        : results.subList(0, 1);
    return Lists.newArrayList(resultsToReturn);
} finally {
    jdoQuery.closeAll();
}
The newArrayList is passed a null value and it then promptly throws an 
exception :
Caused by: java.lang.NullPointerException
 at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:212) 
at com.google.common.collect.Lists.newArrayList(Lists.java:144) at 
org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor.getResults(PersistenceQueryFindUsingApplibQueryProcessor.java:124)
 at 
org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor.process(PersistenceQueryFindUsingApplibQueryProcessor.java:57)
 at 
org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor.process(PersistenceQueryFindUsingApplibQueryProcessor.java:41)
As far as I can see executeWithMap is the culprit here.
Must I log an issue or is this caused by  myself writing bad code?
ThanksGerrie  

Reply via email to