@Target(value=METHOD) @Retention(value=RUNTIME) public @interface SetEntity
Dao
method that fills a core driver data structure from an instance of an
Entity
class.
Example:
public interface ProductDao { @SetEntity BoundStatement bind(Product product, BoundStatement boundStatement); }The generated code will set each entity property on the target, such as:
boundStatement = boundStatement.set("id", product.getId(), UUID.class); boundStatement = boundStatement.set("description", product.getDescription(), String.class); ...It does not perform a query. Instead, those methods are intended for cases where you will execute the query yourself, and just need the conversion logic.
SettableByName
(the most likely candidates are BoundStatement
, BoundStatementBuilder
and UdtValue
). Note that you can't use SettableByName
itself.
The order of the parameters does not matter.
@SetEntity void bind(Product product, UdtValue udtValue); @SetEntity void bind(Product product, BoundStatementBuilder builder);Note that if the settable parameter is immutable, the method should return a new instance, because the generated code won't be able to modify the argument in place. This is the case for
BoundStatement
, which is immutable in the driver:
// Wrong: statement won't be modified @SetEntity void bind(Product product, BoundStatement statement); // Do this instead: @SetEntity BoundStatement bind(Product product, BoundStatement statement);If you use a void method with
BoundStatement
, the mapper processor will issue a
compile-time warning.Modifier and Type | Optional Element and Description |
---|---|
NullSavingStrategy |
nullSavingStrategy
How to handle null entity properties.
|
public abstract NullSavingStrategy nullSavingStrategy
This defaults either to the DAO-level strategy
(if set),
or NullSavingStrategy.DO_NOT_SET
.
Copyright © 2017–2020. All rights reserved.