You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Chris Wolf <cw...@gmail.com> on 2013/02/01 22:28:45 UTC
What is the best practice for handling results from JPQL query?
I notice that upon executing a query with the EM, it returns a
collection list of type "DelagatingResultList" can I just use that in
the business logic of my app, or should I copy it into a standard
ArrayList first?
Thanks,
Chris
Re: What is the best practice for handling results from JPQL query?
Posted by Chris Wolf <cw...@gmail.com>.
Ok, sounds good - thanks for the help.
On Fri, Feb 1, 2013 at 6:14 PM, Craig L Russell
<cr...@oracle.com> wrote:
> Hi Chris,
>
> On Feb 1, 2013, at 1:28 PM, Chris Wolf wrote:
>
>> I notice that upon executing a query with the EM, it returns a
>> collection list of type "DelagatingResultList" can I just use that in
>> the business logic of my app, or should I copy it into a standard
>> ArrayList first?
>
>
> Generally, any type of XXXList<Foo> that you get from "someone else's code"
> should be treated (not copied!) as a List<Foo>. Unless you know that the
> behavior you need is only in XXXList and not in List. So in your Java code,
>
> List<Foo> result = fooQuery.getResultList();
>
> So carefully look at your requirements, but in general just use the
> List<Foo> behavior until you find you need something more. And then ask here
> to see if there's a better way.
>
> Craig
>>
>>
>> Thanks,
>>
>>
>> Chris
>
>
> Craig L Russell
> Architect, Oracle
> http://db.apache.org/jdo
> 408 276-5638 mailto:Craig.Russell@oracle.com
> P.S. A good JDO? O, Gasp!
>
Re: What is the best practice for handling results from JPQL query?
Posted by Craig L Russell <cr...@oracle.com>.
Hi Chris,
On Feb 1, 2013, at 1:28 PM, Chris Wolf wrote:
> I notice that upon executing a query with the EM, it returns a
> collection list of type "DelagatingResultList" can I just use that in
> the business logic of my app, or should I copy it into a standard
> ArrayList first?
Generally, any type of XXXList<Foo> that you get from "someone else's
code" should be treated (not copied!) as a List<Foo>. Unless you know
that the behavior you need is only in XXXList and not in List. So in
your Java code,
List<Foo> result = fooQuery.getResultList();
So carefully look at your requirements, but in general just use the
List<Foo> behavior until you find you need something more. And then
ask here to see if there's a better way.
Craig
>
> Thanks,
>
>
> Chris
Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@oracle.com
P.S. A good JDO? O, Gasp!