Re: [JIRA] Created: (CAY-964) Enum logging in SQL logs

From: Michael Gentry (blacknex..mail.com)
Date: Wed Jan 16 2008 - 13:02:49 EST

  • Next message: Kevin Menard: "Re: [JIRA] Created: (CAY-964) Enum logging in SQL logs"

    I don't mind having the mapping in the Java file itself. That's what
    I did before in this example:

      public static final DateFrequencyEnumeration ANNUALLY = new
    DateFrequencyEnumeration("ANNUALLY", new Integer(1));
    ...
      public static final DateFrequencyEnumeration QUARTERLY = new
    DateFrequencyEnumeration("QUARTERLY", new Integer(4));
      public static final DateFrequencyEnumeration MONTHLY = new
    DateFrequencyEnumeration("MONTHLY", new Integer(12));
    ...

    Mapping ANNUALLY -> 1, QUARTERLY -> 4, MONTHLY -> 12 (integers in this
    case). Of course, this isn't a requirement, I suppose. As long as
    everything gets registered before using them, although then you might
    risk accidentally changing them. I made sure values were uniqued,
    too. All values mapped to QUARTERLY pointed to the same instance, so
    you could use == for equality testing.

    /dev/mrg

    PS. I haven't thought seriously about how to re-implement this using
    Java 1.5 enums (if it is even reasonably possible). I just know that
    the current enum support doesn't map well to real-world usage. Maybe
    annotations make sense, I'm just not sure (I can read up on them).
    PPS. I'm not going to start coding on it today -- plenty of time to
    hash out what is the best for Cayenne if we want native support.

    On Jan 16, 2008 12:49 PM, Andrus Adamchik <andru..bjectstyle.org> wrote:
    > Sorry for the email flood... I jumped the gun on enums. It will be
    > inconsistent with the best Cayenne tradition of keeping the mapping
    > completely separate form the code. So I'd say we'd have to map the
    > stuff below in the DataMap... so we will have to add yet another
    > mapping primitive :-/
    >
    > Andrus
    >
    >
    >
    > On Jan 16, 2008, at 7:42 PM, Andrus Adamchik wrote:
    >
    > >
    > > On Jan 16, 2008, at 7:34 PM, Andrus Adamchik wrote:
    > >
    > >> public enum SomeArbitraryType {
    > >>
    > >> TYPE1, TYPE2, ...;
    > >>
    > >> ..numCode
    > >> public String getCode() {
    > >> // this is dumb, but demonstrates the idea
    > >> return name() + "_CODE";
    > >> }
    > >> }
    > >
    > >
    > > Or this:
    > >
    > > public enum SomeArbitraryType {
    > >
    > > ..bCode(value="X")
    > > TYPE1,
    > >
    > > ..bCode(value="Y")
    > > TYPE2, ...;
    > > }
    > >
    > > Andrus
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Jan 16 2008 - 13:03:21 EST