Re: abstract entities, inheritance, etc.

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Apr 24 2009 - 03:03:15 EDT

  • Next message: Marco Gattei: "Cayenne 3.0.M5 fetch offset"

    >
    > that raises the question of whether we support enum-mapped
    > properties as the discriminators, and if so, what's the proper
    > syntax for specifying the enum constant in the qualifier field?

    We should. This comes down to adding enum literals support in the
    "exp" package. Maybe:

    xyz = org.example.EnumClass.ENUM_NAME

    This is also seems to be the JPA (EJBQL) syntax for enum literals.

    Andrus

    On Apr 24, 2009, at 9:51 AM, Robert Zeigler wrote:

    > This was with a SelectQuery already.
    >
    > Just verified that you're right: this is a problem with my qualifiers.
    >
    > The column type is varchar. I was trying to map the object property
    > as an enum. But I wasn't sure how to specify the qualifier, so I
    > tried as:
    >
    > entryType = 'ENUM_CONST_NAME'
    >
    > Which failed. When I changed the java type of entryType to string,
    > cayenne properly instantiated the subclasses.
    > So I suppose that raises the question of whether we support enum-
    > mapped properties as the discriminators, and if so, what's the
    > proper syntax for specifying the enum constant in the qualifier field?
    >
    > Robert
    >
    > On Apr 24, 2009, at 4/241:23 AM , Andrus Adamchik wrote:
    >
    >>
    >> On Apr 24, 2009, at 5:35 AM, Robert Zeigler wrote:
    >>
    >>> No, it's a bit more complicated. The template is one portion of
    >>> the fix, but even if the entity is marked abstract (in both the
    >>> mapping and the java class), cayenne will try to instantiate it in
    >>> the aforementioned query on superclass case. So a complete
    >>> solution will require that case to resolve and instantiate the
    >>> subclass types, rather than attempting to instantiate the
    >>> superclass type.
    >>>
    >>> Robert
    >>
    >> Hi Robert,
    >>
    >> The whole logic for instantiating an object of a given class is
    >> based on the combination of entity qualifiers in the hierarchy
    >> (including on the base class). So unless this is a bug specific to
    >> EJBQLQuery (could you try the same thing with SelectQuery?), maybe
    >> the condition on a given result set row yielded a base class somehow?
    >>
    >> Could you post the stack trace and entity qualifiers?
    >>
    >> Thanks,
    >> Andrus
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Apr 24 2009 - 03:03:47 EDT