Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
io.realm.annotations

Annotation Type PrimaryKey

Implemented interfaces:

  • java.lang.annotation.Annotation

La anotación @PrimaryKey marcará un campo como clave principal dentro de Realm. Solo un campo en una clase RealmObject puede tener esta anotación, y el campo debe identificar de forma única el objeto. Intentar insertar un objeto con una clave principal existente resultará en un io.realm.exceptions.RealmPrimaryKeyConstraintException La clave principal no se puede cambiar una vez creado el objeto.

Primary keys also count as having the Index annotation.

It is allowed to apply this annotation on the following primitive types: byte, short, int, and long. String, Byte, Short, Integer, Long, ObjectId and UUID are also allowed, and further permitted to have null as a primary key value.

This annotation is not allowed inside Realm classes marked as @RealmClass(embedded = true) .

Volver

LinkingObjects

En esta página