-
Notifications
You must be signed in to change notification settings - Fork 7
Annotations
Here are the annotations you can use within your project for easier database access:
-
@Persistence: The @Persistence annotation is the basic configuration you will need to use. Providing information about the current database version and its name to the framework. A single class has to be annotated with it in your project. Without the @Persistence annotation there will be no code generation.
-
@Update: Declares a class to be the update hook when you change the database version. The annotated class also has to implement the org.droitatedDB.hooks.DbUpdate interface. The update hook is a good place for the @Persistence annotation as well.
-
@Entity: Declares a class to be an entity. Entities can be stored within the database and can have a ContentProvider as well. The @Entity annotation allows controlling the creation of the ContentProvider, its authority and whether or not should be exported.
-
@Column: This annotation can be placed to a field within an @Entity. An annotated field will become a column in the database table of the entity. This allows @Entities to have transient fields besides their persisted fields.
-
@PrimaryKey: Specifies the primary key of an @Entity. Every entity must have exactly one annotated primary key field of the type Integer or Long.
-
@AutoIncrement: A @PrimaryKey annotated field can also be marked with @AutoIncrement to instruct the database to automatically increment the primary key with each new saved entity.
-
@Relationship: If you need associations between @Entity classes you can annotate an entity field with @Relationship. This will link two entities together and generate the necessary information into the database.The annotation is allowed on simple entity fields generating a *:1 association or on Collection fields generation a *:n association.
More detailed information are provided in the JavaDocs.