[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Adding order by to an instance of a named query?
|
If you don't have an order by already on there I believe you can use
the EclipseLink Expression API to transform it, but if there's already
an order by I wouldn't be surprised if it eclipselink just wraps the
query -- though that may just be the behavior on native queries. If
you really need dynamic queries it's best to start with the Expression
API To begin with.
http://wiki.eclipse.org/Introduction_to_EclipseLink_Expressions_(ELUG)
./tch
On Mon, Aug 23, 2010 at 1:12 PM, Laird Nelson <ljnelson@xxxxxxxxx> wrote:
> Hello; how would I use the proprietary EclipseLink APIs to dynamically alter
> the order by clause of an *instance* of a named query?
>
> I have a named query, let's say, defined like this:
>
> @NamedQuery(
> name = "Foo.findAll",
> query = "SELECT f FROM Foo f ORDER BY f.id ASC"
> )
>
> I would like to do something like this:
>
> final Query q = this.em.createNamedQuery("Foo.findAll");
> final SomeClass unwrappedQuery = q.unwrap(SomeClass.class);
> assert unwrappedQuery != null;
> unwrappedQuery.invokeSomeEclipseLinkAPIToAddOrderByInformation(orderByInformationGoesHere);
>
> Is that possible? Or is a Query instance returned by
> EntityManager#createNamedQuery() shared in such a way that any such change
> to its order by information would alter the fundamental named query
> definition?
>
> Thanks,
> Laird
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
>