PrimaryKey



Marks a property in an Entity as the primary key.

If you would like to define a composite primary key, you should use Entity.primaryKeys function.

Each Entity must declare a primary key unless one of its super classes declares a primary key. If both an Entity and its super class defines a PrimaryKey, the child's PrimaryKey definition will override the parent's PrimaryKey.

If this annotation is used on a Embedded property, all columns inherited from that embedded property becomes the composite primary key (including its grand children properties).

Summary

Public constructors

PrimaryKey(autoGenerate: Boolean)
Cmn

Public properties

Boolean

Set to true to let SQLite generate the unique id.

Cmn

Public constructors

PrimaryKey

PrimaryKey(autoGenerate: Boolean = false)

Public properties

autoGenerate

val autoGenerateBoolean

Set to true to let SQLite generate the unique id.

When set to true, the SQLite type affinity for the property should be INTEGER.

If the property type is Long or Int (or its TypeConverter converts it to a Long or Int), Insert functions treat 0 as not-set while inserting the item. Similarly if the property type is nullable Long or Int, Insert functions treat null as not-set while inserting the item.

Returns
Boolean

Whether the primary key should be auto-generated by SQLite or not. Defaults to false.