Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Adding order by to an instance of a named query?

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

Back to the top