@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.Copyright © 2017–2020. All rights reserved.