Re: orderBY with prefetched table

Maxim Petrusevich <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAHmxDgkm6MHa=ZAqmYUH-2CY5ADBKNVXEKHGdbSTNVP4oL0wug@mail.gmail.com>
As I know, Cayenne has ordering which uses list of orderings.

orderBy(Collection<Ordering> orderings)

You should create list with items which will have Ordering type. Something
like this:

List<Ordering> orderings = new ArrayList<>();

orderings.add(new Ordering(attribute, sortOrder))
...

// attribute here, is a string which describes your attribute in "cayenne
style" (e.g. Table1.SOME_FIELD.getName()) // sort order is a cayenne
specified type of ordering: SortOrder.ASCENDING or SorterOrder.DESCENDING,
see SortOrder class for details ObjectSelect.query(Table1.class)
.prefetch(Table1.TO_TABLE2.joint()) .orderBy(orderings)
.select(getObjectContext())


On Mon, Jun 24, 2019 at 11:48 AM abapseres <[email protected]> wrote:

> Hello,
>
> I would like to sort query results with a prefetched table propertie, but
> it don't work :
>
>
> ObjectSelect.query(Table1.class)
>      .prefetch(Table1.TO_TABLE2.joint())
>      .orderBy(Table1.LIBELLE1.asc())
>      .orderBy(Table2.LIBELLE2.asc()) --> dont work
>      .select(getObjectContext())
>
>
> Is it possible to do something like that ?
>
> Thank you
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.