openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tyler Coles" <tylerco...@gmail.com>
Subject Re: org.apache.openjpa.persistence.ArgumentException: -1
Date Wed, 12 Dec 2007 16:33:13 GMT
Well I'm not an expert, but it appears as though you shouldn't be
using getSingleResult(), since your query does not inherently
guarantee that a single result will be returned.  If you check the
javax.persistence.Query JavaDoc, getSingleResult() is supposed to
throw an exception if more than one row results from a query.  I don't
know why OpenJPA complains about argument, looks counter-intuitive to
me: Average Joe User.

I would try getResultList().get(0) if you know for certain that there
is only one row whose parent is null (which I'm sure makes sense in
your application).

Maybe someone can comment as to whether the exception should be more precise.

Tyler


On Dec 11, 2007 5:45 PM, roger.keays <roger.keays@ninthavenue.com.au> wrote:
>
>
> Does anybody recognise this error in openjpa 1.0.0?
>
> <openjpa-1.0.0-r420667:570500 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: -1
>         org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:808)
>         org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:769)
>         org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:765)
>         org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517)
>         org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:238)
>
> org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:300)
>         figbird.cms.application.CMS.getRootItem(CMS.java:249)
>
> The query is:
>
>         query = em.createQuery("SELECT item FROM Page item WHERE " +
>                 "item.parent is null");
>         try {
>             root = (Page) query.getSingleResult();
>         }
>
> If I enhance with 1.0.1 and deploy with 1.0.0 it works without error.
>
> Thanks in advance,
>
> Roger
> --
> View this message in context: http://www.nabble.com/org.apache.openjpa.persistence.ArgumentException%3A--1-tp14286888p14286888.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>

Mime
View raw message