You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by yu wang <wa...@gmail.com> on 2013/05/27 08:12:31 UTC

How to define a timeout for nativeQuery by OpenJPA 1.2.2

*
I found *
*javax.persistence.query.timeout
 does not work.

query = manager.createNativeQuery(sql, Mybean.class);

        query.setHint("openjpa.FetchPlan.LockTimeout", new Integer(30000));
        query.setHint("javax.persistence.lock.timeout", new Integer(30000));
        query.setHint("javax.persistence.query.timeout", new
Integer(30000));

        if (TsamLogger.isInfoEnabled(log)) {
          start_time = System.currentTimeMillis();
        }
        reslist = query.getResultList();

*
*Regards,
Yu Wang
*
**

Re: How to define a timeout for nativeQuery by OpenJPA 1.2.2

Posted by José Luis Cetina <ma...@gmail.com>.
Why you dont paginate the information?
El 29/05/2013 00:00, "yu wang" <wa...@gmail.com> escribió:

> Kevin,
> Some queries are never return due to the big data size so that we need a
> mechanism to make it unblocked with a timeout.
>
> Regards,
> Yu Wang
>
>
> On Tue, May 28, 2013 at 9:48 PM, Kevin Sutter <kw...@gmail.com> wrote:
>
> > Hi Yu Wang,
> > I'm not clear on what you are trying to demonstrate.  The OpenJPA junit
> > bucket does have some tests for the various timeout hints and their usage
> > with finders and queries.  If you can further explain what your expected
> > results should be (via a junit?), it would be helpful.  Thanks,
> >
> > Kevin
> >
> >
> > On Mon, May 27, 2013 at 1:12 AM, yu wang <wa...@gmail.com> wrote:
> >
> > > *
> > > I found *
> > > *javax.persistence.query.timeout
> > >  does not work.
> > >
> > > query = manager.createNativeQuery(sql, Mybean.class);
> > >
> > >         query.setHint("openjpa.FetchPlan.LockTimeout", new
> > Integer(30000));
> > >         query.setHint("javax.persistence.lock.timeout", new
> > > Integer(30000));
> > >         query.setHint("javax.persistence.query.timeout", new
> > > Integer(30000));
> > >
> > >         if (TsamLogger.isInfoEnabled(log)) {
> > >           start_time = System.currentTimeMillis();
> > >         }
> > >         reslist = query.getResultList();
> > >
> > > *
> > > *Regards,
> > > Yu Wang
> > > *
> > > **
> > >
> >
>

Re: How to define a timeout for nativeQuery by OpenJPA 1.2.2

Posted by yu wang <wa...@gmail.com>.
Kevin,
Some queries are never return due to the big data size so that we need a
mechanism to make it unblocked with a timeout.

Regards,
Yu Wang


On Tue, May 28, 2013 at 9:48 PM, Kevin Sutter <kw...@gmail.com> wrote:

> Hi Yu Wang,
> I'm not clear on what you are trying to demonstrate.  The OpenJPA junit
> bucket does have some tests for the various timeout hints and their usage
> with finders and queries.  If you can further explain what your expected
> results should be (via a junit?), it would be helpful.  Thanks,
>
> Kevin
>
>
> On Mon, May 27, 2013 at 1:12 AM, yu wang <wa...@gmail.com> wrote:
>
> > *
> > I found *
> > *javax.persistence.query.timeout
> >  does not work.
> >
> > query = manager.createNativeQuery(sql, Mybean.class);
> >
> >         query.setHint("openjpa.FetchPlan.LockTimeout", new
> Integer(30000));
> >         query.setHint("javax.persistence.lock.timeout", new
> > Integer(30000));
> >         query.setHint("javax.persistence.query.timeout", new
> > Integer(30000));
> >
> >         if (TsamLogger.isInfoEnabled(log)) {
> >           start_time = System.currentTimeMillis();
> >         }
> >         reslist = query.getResultList();
> >
> > *
> > *Regards,
> > Yu Wang
> > *
> > **
> >
>

Re: How to define a timeout for nativeQuery by OpenJPA 1.2.2

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Yu Wang,
I'm not clear on what you are trying to demonstrate.  The OpenJPA junit
bucket does have some tests for the various timeout hints and their usage
with finders and queries.  If you can further explain what your expected
results should be (via a junit?), it would be helpful.  Thanks,

Kevin


On Mon, May 27, 2013 at 1:12 AM, yu wang <wa...@gmail.com> wrote:

> *
> I found *
> *javax.persistence.query.timeout
>  does not work.
>
> query = manager.createNativeQuery(sql, Mybean.class);
>
>         query.setHint("openjpa.FetchPlan.LockTimeout", new Integer(30000));
>         query.setHint("javax.persistence.lock.timeout", new
> Integer(30000));
>         query.setHint("javax.persistence.query.timeout", new
> Integer(30000));
>
>         if (TsamLogger.isInfoEnabled(log)) {
>           start_time = System.currentTimeMillis();
>         }
>         reslist = query.getResultList();
>
> *
> *Regards,
> Yu Wang
> *
> **
>