com.abubusoft.kripton.android.annotation.BindIndex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kripton-orm Show documentation
Show all versions of kripton-orm Show documentation
Kripton Persistence Library - ORM module
The newest version!
/**
*
*/
package com.abubusoft.kripton.android.annotation;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
*
* Annotation used to define table's indexes. It can be used in
* {@link BindSqlType} annotation.
*
*
* Attributes
*
* - value: an array of fields used for index definition.
* You must use field name: Kripton will translate field names in column
* names at compile time. Every field can be followed by `asc` or `desc`
* keyword. Follow this link for
* more information.
* - unique: if true, it defines the index as a unique index:
* the index cannot have the same value for different rows.
*
*
*
* Usage
*
*
@BindType
@BindSqlType(
indexes= {
@BindIndex({"birthCity", "birthDay desc"}),
@BindIndex({"surname"}),
@BindIndex(value={"name","surname", "date desc"}, unique=true )
}
)
public class Person {
...
}
*
*
* The above data model definition will generate the following table definition:
*
*
CREATE TABLE person (id INTEGER PRIMARY KEY AUTOINCREMENT, alias_name TEXT UNIQUE, date TEXT, name TEXT, surname TEXT, birth_city TEXT, birth_day TEXT);
CREATE INDEX idx_person_name ON person(name); CREATE INDEX idx_person_surname ON person(surname);
CREATE UNIQUE INDEX idx_person_0 on person (name, surname, date desc);
CREATE INDEX idx_person_0 on person (birth_city, birth_day desc);
CREATE INDEX idx_person_1 on person (surname);
*
*
* @author Francesco Benincasa ([email protected])
*
*/
@Retention(CLASS)
@Target(ANNOTATION_TYPE)
public @interface BindIndex {
/**
* set of field name used to define index. Field names will be converted at
* compile time
*
* @return field set that define index.
*/
String[] value();
/**
* Indicates if index is unique or not.
*
* @return true if index is unique
*/
boolean unique() default false;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy