Enum PutMethod

java.lang.Object
java.lang.Enum<PutMethod>
io.datarouter.storage.config.PutMethod
All Implemented Interfaces:
io.datarouter.util.enums.IntegerEnum<PutMethod>, io.datarouter.util.enums.PersistentString, io.datarouter.util.enums.StringEnum<PutMethod>, java.io.Serializable, java.lang.Comparable<PutMethod>, java.lang.constant.Constable

public enum PutMethod
extends java.lang.Enum<PutMethod>
implements io.datarouter.util.enums.IntegerEnum<PutMethod>, io.datarouter.util.enums.StringEnum<PutMethod>
Defines the strategy used when writing a databean to a datastore, especially the behavior when trying to put a databean which has a key that already exists.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    java.lang.Enum.EnumDesc<E extends java.lang.Enum<E>>
  • Enum Constant Summary

    Enum Constants 
    Enum Constant Description
    INSERT_IGNORE
    Try to insert the databean and ignore any error that may come up.
    INSERT_ON_DUPLICATE_UPDATE
    Try to insert, or update all the non-key fields if the key already exists.
    INSERT_OR_BUST
    Try to insert the databean, and throw an exception if the primary key already exists.
    INSERT_OR_UPDATE
    Try to insert, and in case of failure, issue an update.
    MERGE  
    SELECT_FIRST_OR_LOOK_AT_PRIMARY_KEY
    Get the primary key first to determine whether to update or insert.
    UPDATE_IGNORE
    Try to update the databean and ignore any error that may come up, like if the primary key does not exist.
    UPDATE_OR_BUST
    Try to update the row at this primary key, and throw an exception if the primary key does not exist.
    UPDATE_OR_INSERT
    Try to update, and in case of failure, issue an insert.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static PutMethod DEFAULT_PUT_METHOD  
    static java.util.Set<PutMethod> METHODS_TO_FLUSH_IMMEDIATELY  
  • Method Summary

    Modifier and Type Method Description
    PutMethod fromPersistentInteger​(java.lang.Integer integer)  
    PutMethod fromPersistentString​(java.lang.String string)  
    java.lang.Integer getPersistentInteger()  
    java.lang.String getPersistentString()  
    boolean getShouldAutoCommit()  
    static PutMethod valueOf​(java.lang.String name)
    Returns the enum constant of this type with the specified name.
    static PutMethod[] values()
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Enum

    clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface io.datarouter.util.enums.IntegerEnum

    fromPersistentIntegerOptional

    Methods inherited from interface io.datarouter.util.enums.StringEnum

    fromPersistentStringOptional
  • Enum Constant Details

    • SELECT_FIRST_OR_LOOK_AT_PRIMARY_KEY

      public static final PutMethod SELECT_FIRST_OR_LOOK_AT_PRIMARY_KEY
      Get the primary key first to determine whether to update or insert. Slow, and may not be thread safe.
    • UPDATE_OR_INSERT

      public static final PutMethod UPDATE_OR_INSERT
      Try to update, and in case of failure, issue an insert. Good to use when rows are usually there.
    • INSERT_OR_UPDATE

      public static final PutMethod INSERT_OR_UPDATE
      Try to insert, and in case of failure, issue an update.
    • INSERT_OR_BUST

      public static final PutMethod INSERT_OR_BUST
      Try to insert the databean, and throw an exception if the primary key already exists.
    • UPDATE_OR_BUST

      public static final PutMethod UPDATE_OR_BUST
      Try to update the row at this primary key, and throw an exception if the primary key does not exist.
    • MERGE

      public static final PutMethod MERGE
    • INSERT_IGNORE

      public static final PutMethod INSERT_IGNORE
      Try to insert the databean and ignore any error that may come up. If the key already exists, or any other error happens, silently abort the put.
    • INSERT_ON_DUPLICATE_UPDATE

      public static final PutMethod INSERT_ON_DUPLICATE_UPDATE
      Try to insert, or update all the non-key fields if the key already exists. Performs the put as a single operation if the datastore supports it. This is the default.
    • UPDATE_IGNORE

      public static final PutMethod UPDATE_IGNORE
      Try to update the databean and ignore any error that may come up, like if the primary key does not exist.
  • Field Details

  • Method Details

    • values

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

      public static PutMethod valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
      java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
      java.lang.NullPointerException - if the argument is null
    • getShouldAutoCommit

      public boolean getShouldAutoCommit()
    • getPersistentInteger

      public java.lang.Integer getPersistentInteger()
      Specified by:
      getPersistentInteger in interface io.datarouter.util.enums.IntegerEnum<PutMethod>
    • fromPersistentInteger

      public PutMethod fromPersistentInteger​(java.lang.Integer integer)
      Specified by:
      fromPersistentInteger in interface io.datarouter.util.enums.IntegerEnum<PutMethod>
    • getPersistentString

      public java.lang.String getPersistentString()
      Specified by:
      getPersistentString in interface io.datarouter.util.enums.PersistentString
    • fromPersistentString

      public PutMethod fromPersistentString​(java.lang.String string)
      Specified by:
      fromPersistentString in interface io.datarouter.util.enums.StringEnum<PutMethod>