Table of Contents
Automatically generation of Dao classes
To create, read, update or delete your data in the database with Room, so called Dao classes are needed. In these classes you define and/or implement data access methods. Most of this code is very repetitive and so called boilerplate code.
RoomEx allows you to simply skip the boilerplate code needed to create these Dao classes, with the help of the @AutoDao annotation, which is available for every entity.
@AutoDao(val packageName: String = "")
During the annotation processing of RoomEx, a @DaoEx class will created for every entity annotated with @AutoDao. In the next processing round, the @DaoEx will then be processed and a @Dao class will generated for Room.
The optional argument packageName allows you to define the target package name for the generated class.
The generated Dao will implement all functions from the ICrud<T> interface. A complete list can be found here: Dao methods.
Example
Taken from the Sample-App in this repository.
@Entity
@AutoDao // Automtically generate a Dao for this entity. Must be accompanied by @Entity
data class DummyAuto(
@ColumnInfo
var sample: String
) : RoomExEntity() {
@Ignore @OneToManyEx(allCascade = true)
var users: MutableList<User>? = null
@Ignore @OneToOneEx(allCascade = true)
var address: Address? = null
}