Class EnumValueHandler

java.lang.Object
org.apache.openjpa.jdbc.meta.strats.AbstractValueHandler
org.apache.openjpa.jdbc.meta.strats.EnumValueHandler
All Implemented Interfaces:
Serializable, ValueHandler

public class EnumValueHandler extends AbstractValueHandler
Value handler for JDK1.5 enum field types.
See Also:
  • Constructor Details

    • EnumValueHandler

      public EnumValueHandler()
  • Method Details

    • getStoreOrdinal

      public boolean getStoreOrdinal()
      Whether to store the enum value as its ordinal.
    • setStoreOrdinal

      public void setStoreOrdinal(boolean ordinal)
      Whether to store the enum value as its ordinal.
    • getUseEnumeratedValue

      public boolean getUseEnumeratedValue()
      Whether to use the @EnumeratedValue annotated field for DB mapping.
    • setUseEnumeratedValue

      public void setUseEnumeratedValue(boolean useEnumeratedValue)
      Whether to use the @EnumeratedValue annotated field for DB mapping.
    • map

      @Deprecated public Column[] map(ValueMapping vm, String name, ColumnIO io, boolean adapt)
      Deprecated.
      Description copied from interface: ValueHandler
      Map the given value and return all mapped columns, or simply return an array of unmapped default columns. The columns should have at least their Name and JavaType properties set.
      Parameters:
      name - use as a base to form column name(s); the column names of unmapped columns will automatically be made to fit database limitations
      io - I/O information about mapped columns; you do not have to set this information if returning templates
      adapt - whether to adapt the mapping or schema
    • map

      public Column[] map(ValueMapping vm, DBIdentifier name, ColumnIO io, boolean adapt)
    • strategy

      public static String strategy(Class<?> enumType, boolean ordinal)
      Return the value handler strategy to use for the given enum type. An enum type with an @EnumeratedValue field is always mapped by that value, as the JPA 3.2 specification gives it precedence over the ordinal/name choice; every place that configures this handler from metadata has to go through here, so that one enum type is encoded the same way no matter which kind of metadata declared it.
    • hasEnumeratedValue

      public static boolean hasEnumeratedValue(Class<?> enumType)
      Check if the given enum type has a field annotated with @EnumeratedValue.
    • isVersionable

      public boolean isVersionable(ValueMapping vm)
      Description copied from interface: ValueHandler
      Return whether the values managed by this handler can be used in state image versioning.
      Specified by:
      isVersionable in interface ValueHandler
      Overrides:
      isVersionable in class AbstractValueHandler
    • toDataStoreValue

      public Object toDataStoreValue(ValueMapping vm, Object val, JDBCStore store)
      Description copied from interface: ValueHandler
      Translate the given value to its datastore equivalent. If this value occupies multiple columns, return an object array with one element per column. For relation id columns, return the state manager the column depends on.
      Specified by:
      toDataStoreValue in interface ValueHandler
      Overrides:
      toDataStoreValue in class AbstractValueHandler
    • toObjectValue

      public Object toObjectValue(ValueMapping vm, Object val)
      Description copied from interface: ValueHandler
      Translate the given datastore value into its Java equivalent. If the value occupies multiple columns, the given object will be an object array with one entry per column. This method is only called if ValueHandler.objectValueRequiresLoad(ValueMapping) returns false.
      Specified by:
      toObjectValue in interface ValueHandler
      Overrides:
      toObjectValue in class AbstractValueHandler