@Target(value=METHOD) @Retention(value=RUNTIME) public @interface GetEntity
Dao
method that converts a core driver data structure into one or more
instances of an Entity
class.
Example:
@Dao public interface ProductDao { @GetEntity Product asProduct(Row row); }The generated code will retrieve each entity property from the source, such as:
Product product = new Product(); product.setId(row.get("id", UUID.class)); product.setDescription(row.get("description", String.class)); ...
It does not perform a query. Instead, those methods are intended for cases where you already have a query result, and just need the conversion logic.
GettableByName
or one of its subtypes (the most likely candidates are Row
and UdtValue
).
ResultSet
.
AsyncResultSet
.
null
if the result set is empty.
@GetEntity Product asProduct(Row row); @GetEntity Product firstRowAsProduct(ResultSet resultSet);
PagingIterable
of an entity class. In that case, the type of the parameter
must be ResultSet
. Each row in the result set will be converted into an
entity instance.
@GetEntity PagingIterable<Product> asProducts(ResultSet resultSet);
MappedAsyncPagingIterable
of an entity class. In that case, the type of the
parameter must be AsyncResultSet
. Each row in the result set will be
converted into an entity instance.
@GetEntity MappedAsyncPagingIterable<Product> asProducts(AsyncResultSet resultSet);
PagingIterable
for
AsyncResultSet
), the mapper processor will issue a compile-time error.Modifier and Type | Optional Element and Description |
---|---|
boolean |
lenient
Whether to tolerate missing columns in the source data structure.
|
public abstract boolean lenient
If false
(the default), then the source must contain a matching column for every
property in the entity definition, including computed ones. If such a column is not
found, an IllegalArgumentException
will be thrown.
If true
, the mapper will operate on a best-effort basis and attempt to read all
entity properties that have a matching column in the source, leaving unmatched properties
untouched. Beware that this may result in a partially-populated entity instance.
Copyright © 2017–2021. All rights reserved.