Package io.datarouter.storage.config
Enum PutMethod
- All Implemented Interfaces:
io.datarouter.util.enums.IntegerEnum<PutMethod>,io.datarouter.util.enums.PersistentString,io.datarouter.util.enums.StringEnum<PutMethod>,Serializable,Comparable<PutMethod>,java.lang.constant.Constable
public enum PutMethod extends 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
-
Enum Constant Summary
Enum Constants Enum Constant Description INSERT_IGNORETry to insert the databean and ignore any error that may come up.INSERT_ON_DUPLICATE_UPDATETry to insert, or update all the non-key fields if the key already exists.INSERT_OR_BUSTTry to insert the databean, and throw an exception if the primary key already exists.INSERT_OR_UPDATETry to insert, and in case of failure, issue an update.MERGESELECT_FIRST_OR_LOOK_AT_PRIMARY_KEYGet the primary key first to determine whether to update or insert.UPDATE_IGNORETry to update the databean and ignore any error that may come up, like if the primary key does not exist.UPDATE_OR_BUSTTry to update the row at this primary key, and throw an exception if the primary key does not exist.UPDATE_OR_INSERTTry to update, and in case of failure, issue an insert. -
Field Summary
Fields Modifier and Type Field Description static PutMethodDEFAULT_PUT_METHODstatic Set<PutMethod>METHODS_TO_FLUSH_IMMEDIATELY -
Method Summary
Modifier and Type Method Description PutMethodfromPersistentInteger(Integer integer)PutMethodfromPersistentString(String string)IntegergetPersistentInteger()StringgetPersistentString()booleangetShouldAutoCommit()static PutMethodvalueOf(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.
-
Enum Constant Details
-
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
Try to update, and in case of failure, issue an insert. Good to use when rows are usually there. -
INSERT_OR_UPDATE
Try to insert, and in case of failure, issue an update. -
INSERT_OR_BUST
Try to insert the databean, and throw an exception if the primary key already exists. -
UPDATE_OR_BUST
Try to update the row at this primary key, and throw an exception if the primary key does not exist. -
MERGE
-
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
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
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
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
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:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getShouldAutoCommit
public boolean getShouldAutoCommit() -
getPersistentInteger
- Specified by:
getPersistentIntegerin interfaceio.datarouter.util.enums.IntegerEnum<PutMethod>
-
fromPersistentInteger
- Specified by:
fromPersistentIntegerin interfaceio.datarouter.util.enums.IntegerEnum<PutMethod>
-
getPersistentString
- Specified by:
getPersistentStringin interfaceio.datarouter.util.enums.PersistentString
-
fromPersistentString
- Specified by:
fromPersistentStringin interfaceio.datarouter.util.enums.StringEnum<PutMethod>
-