Database interface - generated repositories
IMPORTANT! From GSF version 7.0.0 onwards, code generation for database repositories is disabled by default. To re-enable code generation, change the generateRepositories setting inside the build.gradle.kts files for the genesis-generated-dao and genesis-generated-view modules, as shown below:
codeGen {
generateRepositories = true
}
During the code generation phase, repository classes are generated for every table and view in the system. These repositories provide a type-safe way of accessing the database.
The main differences between the generated repositories and the Entity Db are:
- The entity db can handle any database entity, each repository can only handle a single entity.
- The generated repositories have specific methods for every index of table/view, whereas the entity db is fully generic.
Generated Repositories | |
---|---|
Supports tables | ✔️ |
Supports views | ✔️ |
Supports any data type | ❌ |
Class to import | [TableName]AsyncRepository \ [TableName]Rx3Repository |
Type-safe read and write | ✔️ |
Type-safe write result | ❌ |
Returns data as | table or view entities |
Writes data as | table or view entities |
References indexes as | Generated methods |
Programming interface | Async or RxJava |
Write (input) | Generated |
Write (output) | Write Result |
Subscribe | Record Update of entity |
Bulk or Range Subscribe | Bulk of entity |
Available in Event Handlers | ❌ |
Available in custom Request Servers | ❌ |
With generated repositories, there are two flavours of the entity db:
-
one has a RxJava API signatures, for use from Java
-
the other flavour has an Async API signature, for use by Kotlin
If you have a table called POSITION, then, when you run a generateDao, two repositories will be generated: PositionRx3Repository and PositionAsyncRepository.
You can perform CRUD operations on Table/View by its primary key and indices.