> Everything works fine if I use fetch plan to load the collections (which I
> prefer) but I'm generally afraid of this due to bug [1].

> [1] https://issues.apache.org/jira/browse/OPENJPA-1424

Use FetchPlan. OPENJPA-1424 is fixed.


Daryl Stultz wrote:
> 
> Hello,
> 
> I'm hoping someone can tell me how this could happen:
> 
> <openjpa-1.2.1-r752877:753278 nonfatal user error>
> org.apache.openjpa.persistence.NonUniqueResultException:
> The query on candidate type "class ...model.User"
> with filter
> "select distinct o from User as o
> left join fetch o.validRoles
> left join fetch o.excludedConsultants
> left join fetch o.excludedPatientConsiderations
> left join fetch o.excludedProcedures where o.id = :id"
> was configured to have a unique result, but more than one instance matched
> the query.
>         at
> org.apache.openjpa.kernel.QueryImpl.singleResult(QueryImpl.java:1296)
>         at
> org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1221)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:848)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:779)
>         at
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:525)
>         at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
>         at
> org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:317)
> 
> When run in isolation in test app it works fine. My real usage is that I'm
> trying to "load deep" the user. So I have a detached user instance and I'm
> reloading the user fetching the various collections. It's possible the
> user
> instance is in the L1 cache. Perhaps OpenJPA is including the cached user
> instance in the results. I know there are bugs related to left join and
> distinct but I'm not sure if this is a variation of it.
> 
> Everything works fine if I use fetch plan to load the collections (which I
> prefer) but I'm generally afraid of this due to bug [1].
> 
> [1] https://issues.apache.org/jira/browse/OPENJPA-1424
> 
> -- 
> Daryl Stultz
> _____________________________________
> 6 Degrees Software and Consulting, Inc.
> http://www.6degrees.com
> mailto:da...@6degrees.com
> 
> 


-----
Pinaki 
-- 
View this message in context: 
http://n2.nabble.com/Non-unique-error-tp4293631p4302888.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to