cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: entity Qualifiers and enums
Date Fri, 04 Oct 2019 06:00:36 GMT
I forgot. We can actually parse enums from expression literals. The syntax is as follows:

"someProperty = enum:com.foo.EnumType.ENUM_VALUE"

I.e. a keyword "enum:" plus fully qualified name plus enum object name.

Andrus

> On Oct 3, 2019, at 8:28 PM, Tony Giaccone <tony@giaccone.org> wrote:
> 
> Andrus,
> 
> this is looking more and more like a bug. The exception that gets thrown is
> the Qualifier looks like : accountType = AcountType.HD_ACCOUNT
> 
> org.apache.cayenne.exp.ExpressionException: [v.4.0.B2 Sep 26 2017 10:05:06]
> Can't resolve path component: [AccountInfo.AccountType].
> 
> The problem seems to be that the qualifier which has AccountType.HD_ACOCUNT
> is being looked for as an attribute of the entity.
> 
> I tired setting the qualifier to the string value of the Enum accountType =
> "HD_ACCOUNT" but that causes problems when Cayenne tries to insert the enum
> into the object.
> 
> I think for now, I've changed the implementation so that there's an
> accountTypeStr, which is used as the qualifier, and a cover method that sts
> the enum.
> 
> 
> Tony
> 
> 
> 
> On Wed, Oct 2, 2019 at 11:18 AM Andrus Adamchik <andrus@objectstyle.org>
> wrote:
> 
>> 
>> 
>>> On Oct 1, 2019, at 11:23 PM, Tony Giaccone <tony@giaccone.org> wrote:
>>> 
>>> I have two objects, that are based on the same table. I want to
>> differentiate them by using a qualifier.
>>> 
>>> I'm using a qualifer that looks like accountType = AccountType.hdaccount
>>> 
>>> where hdaccount is one of the enumerated values.
>>> 
>>> When i create an object of this type, the field is set to null. Is that
>> typical? Do I have to explicitly set it myself, if so what happens if I set
>> it to the wrong value?
>> 
>> At least with numeric qualifier values, Cayenne injects qualifier values
>> based on the object type right inside "context.newObject(..)". I am looking
>> at the unit tests now. We have this functionality and it is working.
>> 
>> Not sure we've tested this with enums though. Could be a bug, as the
>> expectation is that it should work with all kinds of constants.
>> 
>> Andrus


Mime
View raw message