If a column has a single PrimaryKey column, a PrimaryKey interface is used do describe it.
If table has many PrimaryKey columns, a PrimaryCompositeKey is in use.
PrimaryKey interface privides informations like Entity class, Column value class and Column interface as follows.
Single colID method unifies an access to primary key column.
If more tables is in use to point the PrimaryKey, Daobab generated another Java class describing a table composite key.
Usually, such class has the table class name with a Key suffix.
Key describes an object composed by all key columns.
PrimaryCompositeKey points to this class type and links it with current entity.
Both PrimaryKey and PrimaryCompositeKey provides a lot of useful methods as well.
- all basic CRUD methods like insert, update, delete, findById
- many useful find methods, including finding another, related entities
Another PrimaryKey related issue is an IdGeneration.
There is a few generation types located into IdGeneratorType.
Entity may be annotated with @IdGenerator to provide the correct generation type
SEQUENCE - Annotation @IdGeneration or method getSequenceName() has to bprovide the correct database sequence name, which will be invoked during an insert, to get Id.
AUTO_INCREMENT - database generates a PrimaryKey id
GENERATOR - application provides an inner generator. In that case, Target method getPrimaryKeyGenerator must me overridden and need to return appropriated generator related to given entity.
NONE - Daobab will take no action related to PrimaryKey id (defaut)
Example of entity with sequence Id generator