@Target(value={TYPE,FIELD,METHOD,PARAMETER}) @Retention(value=RUNTIME) public @interface CqlName
Entity
class or one of its properties (field or getter), to specify a custom
CQL name.
This annotation can also be used to annotate DAO method parameters when they correspond to
bind markers in custom WHERE
clauses; if the parameter is not annotated with CqlName
, its programmatic name will be used instead as the bind marker name.
Beware that if the DAO interface was pre-compiled and is located in a jar, then all its bind
marker parameters must be annotated with CqlName
; failing to do so will result in a
compilation failure because class files do not retain parameter names by default. If you intend
to distribute your DAO interface in a pre-compiled fashion, it is preferable to always annotate
such method parameters.
Example:
@Entity public class Product { @PartitionKey @CqlName("product_id") private int id; ... } @Dao public class ProductDao { @Query("SELECT count(*) FROM ${qualifiedTableId} WHERE product_id = :product_id") long countById(@CqlName("product_id") int id); ... }This annotation takes precedence over the
naming strategy
defined for the
entity.public abstract String value
If you want it to be case-sensitive, it must be enclosed in double-quotes, for example:
@CqlName("\"productId\"") private int id;
Copyright © 2017–2022. All rights reserved.