Re: Expression to compare a property against another property

Faizel Dakri <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <[email protected]>
Michael,

I’m currently using 4.2.  And thank you for the offer of assistance. 

After reading John’s reply and taking a closer look at the CompariableProperty interface, I’ve since found what I needed. I am using ExpressionFactory rather than the Property instances because I’m creating the expressions programmatically.

Thanks,


> On Sep 10, 2020, at 05:34 PM, Michael Gentry <[email protected]> wrote:
> 
> Hi Faizel,
> 
> What version of Cayenne are you using?  That will influence the feedback we
> can provide.
> 
> 
> On Thu, Sep 10, 2020 at 5:00 PM Faizel Dakri <[email protected]> wrote:
> 
>> Is there a facility in Cayenne to create an expression that would compare
>> a property of one object against another property (maybe via a relationship
>> path rooted at the same object) rather than against a scalar value?
>> 
>> I’m trying to port over some old EOF code and we used to have a
>> EOKeyComparisonQualifier which would allow you to create a qualifier to
>> compare a property’s value with that of another property (or property key
>> path).
>> 
>> For example, given a model consisting of employees, where each employee
>> can have a relationship to a manager and each employee has a salary
>> property, you could use a key comparison qualifier to find those employees
>> that are making more than their manager:
>> 
>>        salary > manager.salary
>> 
>> I’ve looked in ExpressionFactory and through some of the source, but to me
>> it looks like all comparison nodes in an expression operate on a key and a
>> scalar. Am I missing something?
>> 
>> Thanks for any help or pointers,
>> 
>> F
>> 
>> --
>> Faizel Dakri
>> 
>> 
>>
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.