jpa-spec
  1. jpa-spec
  2. JPA_SPEC-47

Usability of @Enumerated and @MapKeyEnumerated

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Labels:
      None

      Description

      In mapping a pre-existing schema, it is rarely possible to map a given set of constants using an @Enumerated:

      • Ordinals are non-sequential
      • Names are incompatible with Java Enum Constants
      • Names cannot be aliased to something more useful or conventional for Java Naming standards

      Limitation is because specification states the name() will be used of an enum.
      A typical example: Database uses 'N/A', which can never be mapped to an enum. Intuition will let us look for a solution to map this to 'NOT_AVAILABLE', both a valid name for an Enum Constant, and also conventional naming.

      On top of this, an enum often has a representation in the Database, and a constant has usually other additional attributes that could be useful.
      Better than using the name() of an @Enumerated, we should map the enumerated similar as an @Entity, and use the @ID.

        Activity

        jd3714att created issue -
        ldemichiel made changes -
        Field Original Value New Value
        Assignee ldemichiel [ ldemichiel ]

          People

          • Assignee:
            ldemichiel
            Reporter:
            jd3714att
          • Votes:
            6 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated: