cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Musall, Maik" <>
Subject Re: Ordering using non-property values
Date Mon, 17 Jul 2017 14:40:39 GMT
Hi John,

> Am 17.07.2017 um 16:08 schrieb John Huss <>:
> Expressions will work with non-modeled properties as long as the methods
> look like getters - have the "get" prefix and no arguments.

Unfortunately not:

Caused by: java.lang.IllegalArgumentException: Property 'getCustomerNameForSorting' is not
	at org.apache.cayenne.reflect.BeanAccessor.<init>(
	at org.apache.cayenne.reflect.PropertyUtils.createSegmentAccessor(
	at org.apache.cayenne.reflect.PropertyUtils.getOrCreateSegmentAccessor(
	at org.apache.cayenne.reflect.PropertyUtils$PathAccessor.getValue(
	at org.apache.cayenne.reflect.PropertyUtils.getProperty(
	at org.apache.cayenne.CayenneDataObject.readSimpleProperty(
	at org.apache.cayenne.CayenneDataObject.readNestedProperty(
	at org.apache.cayenne.CayenneDataObject.readNestedProperty(
	at org.apache.cayenne.exp.parser.ASTObjPath.evaluateNode(
	at org.apache.cayenne.exp.parser.SimpleNode.evaluate(

Signature is: public String getCustomerNameForSorting()

> But I would use this:
> Collections.sort(list, (a,b) -> a.getSomeProp().compareTo(b.getSomeProp()));

Thought of that, but it would require me to re-implement the path segment tokenization and


> On Mon, Jul 17, 2017 at 8:08 AM Musall, Maik <> wrote:
>> Hi all,
>> I have a UI with a list of objects and user-configurable filters and
>> sorting criteria. Most of the sorting criteria are plain db path
>> expressions, so I can just feed them into Ordering.orderedList(objects).
>> A couple of them however are path expressions with the last segment being
>> not a Property, but a method name that is supposed to be invoked, which
>> would then return a String, after which the list is to be ordered. This
>> worked fine in the past using EOF and EOSortOrdering, but Cayenne's
>> ordering throws an ExpressionException on evaluate().
>> What is the usual way in Cayenne to deal with this?
>> Thanks
>> Maik

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message