Hi Jérémy,
first, I'd always recommend using the Property objects from your template
superclass to construct expressions, rather than literal strings, to facilitate
refactoring and occurrence searches. So that would then be
Expression e = Artist.CUSTOMED_NAME.like( "Bob" )
or at least
Expression e = ExpressionFactory.likeExp( Artist.CUSTOMED_NAME_KEY,
"Bob" );
But if customedName() is just a method and not an actual Cayenne Property, this
can't work. In that case, just use plain Java:
List<Artist> filtered = e.stream().filter( artist ->
"Bob".equalsIgnoreCase( artist.customedName() ) ).collect( toList() );
Maik
> Am 15.04.2019 um 14:05 schrieb Jérémy DE ROYER <[email protected]>:
>
> Hello,
>
> Does Cayenne supports in-memory filtering ? (like EOF does, I mean without
> takinbg car if it’s sql ou java)
>
> As explained is the doc, I wrote without any effort :
>
> Expression e = Artist.NAME.in<http://Artist.NAME.in>("John", "Bob");
>
>
> List<Artist> filtered = e.filterObjects(unfiltered);
>
> Then, I made a new method and change the expression but without success :
>
> Expression e = ExpressionFactory.likeExp("customedName", "Bob"); // where
> customedName() is a method cloning name()
>
>
> List<Artist> filtered = e.filterObjects(unfiltered);
>
> But an error raised :
>
> org.apache.cayenne.exp.ExpressionException: [v.4.0 Aug 06 2018 12:11:43]
> Error evaluating expression ‘customedName like "Bob"'
>
> Any idea ?
>
> Jérémy