Re: Enums

From: Michael Gentry (blacknex..mail.com)
Date: Fri Aug 10 2007 - 09:36:33 EDT

  • Next message: Andrus Adamchik: "Re: NPE in DataDomainQueryAction.java"

    Another thing I was just thinking about. The current implementation
    is somewhat fragile. When persisting the enumerated value, for an int
    column it calls value.ordinal(), which returns the zero-based index of
    the value of the enum, as it is declared in the class.

    Given:

    public enum Color { Red, Green, Blue }

    Cayenne would persist Red=>0, Green=>1, Blue=>2, but if someone later
    changed the enum to be:

    public enum Color { Red, White, Green, Blue }

    Well, things start falling apart at that point. The values of Green
    and Blue have been changed, but from a Java-perspective, all seems
    fine.

    /dev/mrg



    This archive was generated by hypermail 2.0.0 : Fri Aug 10 2007 - 09:37:05 EDT