Hi Gerrie,
Glad you tracked it down.

It seems to me that the framework ought to cater for a null being returned
from SELECT UNIQUE.

Normally we'd ask you to log an issue, but I've gone ahead and logged one
already [1]

Thanks for reporting this.

Cheers
Dan

[1] https://issues.apache.org/jira/browse/ISIS-1802

On Sun, 24 Dec 2017 at 12:24 Gerrie Myburgh
<[email protected]> wrote:

>  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