Module eclipselink

Enum Class OrderCorrectionType

java.lang.Object
java.lang.Enum<OrderCorrectionType>
org.eclipse.persistence.annotations.OrderCorrectionType
All Implemented Interfaces:
Serializable, Comparable<OrderCorrectionType>, Constable

public enum OrderCorrectionType extends Enum<OrderCorrectionType>
The OrderCorrectionType enum is used with OrderCorrection annotation that could be applied together with OrderColumn annotation. OrderCorrectionType defines a strategy taken in case the order list read from the database is invalid (has nulls, duplicates, negative values, values greater/equal to list size - the only valid order list of n elements is: {0, 1,..., n-1}).

OrderCorrectionType also could be set directly into CollectionMapping using CollectionMapping.setOrderCorrectionType(OrderCorrectionType) method.

See Also:
  • Enum Constant Details

    • READ

      public static final OrderCorrectionType READ
      Order of the list read into application is corrected, but no knowledge is kept about the invalid list order left in the database. This is no problem in case of a read-only usage of the list, but in case the list is modified and saved back into the database the order likely will not be the same as in cache and will be invalid.

      This mode is used by default in case the mapped attribute is neither List nor Vector (more precisely: is not assignable from Eclipselink internal class IndirectList).

      Example:

      a list of three objects:
      in the database: {null, objectA}; {2, objectB}, {5, ObjectC};
      read into application as a list: {objectA, objectB, objectC};
      add a new element to the list: {objectA, objectB, objectC, objectD};
      updated list saved to the db: {null, objectA}, {2, objectB}, {5, objectC}, {3, objectD};
      read again into application: {objectA, objectB, objectD, objectC};
    • READ_WRITE

      public static final OrderCorrectionType READ_WRITE
      Order of the list read into application is corrected, and remembered that the invalid list order left in the database. If the list is updated and saved back into the database then all the order indexes are saved ensuring that the list order in the database will be exactly the same as in cache (and therefore valid).

      This mode is used by default in case the mapped attribute is either List or Vector (more precisely: is assignable from Eclipselink internal class IndirectList).

      JPA uses this mode in case OrderCorrection annotation is not specified.

      Example:

      a list of three objects:
      in the database: {null, objectA}; {2, objectB}, {5, ObjectC};
      read into application as a list: {objectA, objectB, objectC};
      add a new element to the list: {objectA, objectB, objectC, objectD};
      updated list saved to the db: {0, objectA}, {1, objectB}, {2, objectC}, {3, objectD};
      read again into application: {objectA, objectB, objectC, objectD};
    • EXCEPTION

      public static final OrderCorrectionType EXCEPTION
      Don't correct, throw QueryException with error code QueryException.LIST_ORDER_FIELD_WRONG_VALUE

      Example:

      a list of three objects:
      in the database: {null, objectA}; {2, objectB}, {5, ObjectC};
      read into application: exception
  • Method Details

    • values

      public static OrderCorrectionType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static OrderCorrectionType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null