public enum NullSavingStrategy extends Enum<NullSavingStrategy>
Entity
properties will be handled during data insertion.Enum Constant and Description |
---|
DO_NOT_SET
Do not insert null properties.
|
SET_TO_NULL
Insert null properties as a CQL
NULL . |
Modifier and Type | Method and Description |
---|---|
static NullSavingStrategy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static NullSavingStrategy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final NullSavingStrategy DO_NOT_SET
In other words, the mapper won't call the corresponding setter on the BoundStatement
. The generated code looks approximately like this:
if (entity.getDescription() != null) { boundStatement = boundStatement.setString("description", entity.getDescription()); }This avoids inserting tombstones for null properties. On the other hand, if the query is an update and the column previously had another value, it won't be overwritten.
Note that unset values are only supported with native
protocol v4
(Cassandra 2.2) or above. If you try to use this strategy with a lower Cassandra
version, the mapper will throw a MapperException
when you try to build the
corresponding DAO.
public static final NullSavingStrategy SET_TO_NULL
NULL
.
In other words, the mapper will always call the corresponding setter on the BoundStatement
. The generated code looks approximately like this:
// Called even if entity.getDescription() == null boundStatement = boundStatement.setString("description", entity.getDescription());
public static NullSavingStrategy[] values()
for (NullSavingStrategy c : NullSavingStrategy.values()) System.out.println(c);
public static NullSavingStrategy valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullCopyright © 2017–2021. All rights reserved.