Skip to content

@BindIndex

xcesco edited this page May 2, 2018 · 3 revisions

Annotation used to define table's indexes. It can be used in @BindTable 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
@BindTable(
  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);

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally