Skip to content

Latest commit

 

History

History
 
 

daos

README.md

DAOs

A DAO is an interface that defines a set of query methods. In general, those queries will relate to the same entity (although that is not a requirement).

It must be annotated with @Dao:

@Dao
public interface ProductDao {
  @Select
  Product findById(UUID productId);

  @Insert
  void save(Product product);

  @Delete
  void delete(Product product);
}

Query methods

To add queries, define methods on your interface and mark them with one of the following annotations:

The methods can have any name. The allowed parameters and return type are specific to each annotation.

Runtime usage

To obtain a DAO instance, use a factory method on the mapper interface.

InventoryMapper inventoryMapper = new InventoryMapperBuilder(session).build();
ProductDao dao = inventoryMapper.productDao("someKeyspace");

The returned object is thread-safe, and can securely be shared throughout your application.