[ 
https://issues.apache.org/jira/browse/ISIS-1802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16306707#comment-16306707
 ] 

Dan Haywood commented on ISIS-1802:
-----------------------------------

I couldn't reproduce this.  Using the kitchensink app:

ParentObject query:
{code}
       @Query(
                name = "findUnique",
                value = "SELECT "
                        + "FROM 
org.isisaddons.app.kitchensink.dom.hierarchy.parent.ParentObject "
                        + "WHERE name == :name ")
}{code}

ParentObjects repository, tried both uniqueMatch
{code}
    @MemberOrder(sequence = "30.2")
    public ParentObject findUnique(
            @ParameterLayout(named="Name")
            final String name) {
        return repositoryService.uniqueMatch(
                new QueryDefault<>(ParentObject.class,
                        "findUnique",
                        "name", name));
    }
{code}

and firstMatch:
{code}
    @MemberOrder(sequence = "30.2")
    public ParentObject findUnique(
            @ParameterLayout(named="Name")
            final String name) {
        return repositoryService.firstMatch(
                new QueryDefault<>(ParentObject.class,
                        "findUnique",
                        "name", name));
    }
{code}

with update to HierarchyObjects to call:
{code}
    @Action(semantics = SemanticsOf.SAFE)
    @MemberOrder(sequence = "11.1")
    public ParentObject findParentUnique(String name) {
        return parentObjects.findUnique(name);
    }
{code}

In both cases (when matching for existing "Parent 1" and non-existent "xxx"), I 
didn't see any NPE.

~~~
All that said,  I've added in some code anyway within 
PersistenceQueryFindUsingApplibQueryProcessor to check for a returned null, and 
handle approprirately.

~~~
Also, since firstMatch and uniqueMatch are almost identical, I've decided to 
deprecate firstMatch.  This will allow us to simplify the implementation in the 
future, because both allMatches and uniqueMatch work with a QueryCardinality of 
MULTIPLE whereas only firstMatch has a QueryCardinality of SINGLE.

> JDOQL using SELECT UNIQUE causes NPE to be thrown.
> --------------------------------------------------
>
>                 Key: ISIS-1802
>                 URL: https://issues.apache.org/jira/browse/ISIS-1802
>             Project: Isis
>          Issue Type: Bug
>    Affects Versions: 1.15.1
>            Reporter: Dan Haywood
>            Assignee: Dan Haywood
>            Priority: Minor
>             Fix For: 1.16.0
>
>
> as per 
> https://lists.apache.org/thread.html/4658ae59347ee600242d1bc8fae7afebd912111799aad36b74ac57fd@%3Cusers.isis.apache.org%3E



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to