@Entity class should be added in constructor as it is also a default and suggested way of creating and initialising properties in
Kotlin. This way you can insure that your room lib code will work on each versions. (I have used it and tried it in all release since Kotlin is official android language)).
@Query methods in DAO class, parameters should be used like :
arg0, arg1,..., argN.
@Query("select * from post where id = :arg0 and name like :arg1?) fun findPostByIdName(id: Long, name: String): DbPost
@Query methods this way will avoid
Each bind variable in the query must have a matching method parameter. Cannot find method parameters for :p0. error.
Kotlin has just release its 1.1.4 on 15th Aug(two days back), i am not sure if exact param names are allowed in this release or not.
I have not used
apply plugin: 'kotlin-kapt' in my room-kotlin implementation. It wasn't working for me.
having this line
kapt "android.arch.persistence.room:compiler:1.0.0-alpha1" is necessary because its annotation processor for Room lib and without it there is no meaning of annotations(like:
@DAO etc) used for Room implementation.
Check this article: https://medium.com/@chandilsachin/room-with-unit-test-in-kotlin-4ad31a39a291
Have a look at this stackoverflow question to have more insight: Room Persistence lib implementation in Kotlin
Hope it helps.