79311755

Date: 2024-12-27 12:10:33
Score: 1
Natty:
Report link

I got understood what you are saying . I have a similar question recently and I found its easy to solve it. Just simply follow the Android Developers Rooms Official Instructions, than it will automatically generate the codes like it's done on android target.

// your build.gradle.kts may be like:
plugins {
    alias(kotlinx.plugins.jvm)
    alias(kotlinx.plugins.google.ksp)
    alias(androidx.plugins.room)
}
dependencies {
    implementation(androidx.room.runtime)
    implementation(androidx.sqlite.bundled)
    ksp(androidx.room.compiler)
}
room {
    schemaDirectory("$projectDir/schemas")
    schemaDirectory("debug", "$projectDir/schemas/debug")
    schemaDirectory("release", "$projectDir/schemas/release")
}
//database.kt

@Database(
    version = 1,
    entities = [
        SomeEntity::class,
    ]
)
//@TypeConverters(Convertors::class)
abstract class SomeDatabase: RoomDatabase() {
    abstract fun dao():DAO
}
//dao
@Dao
interface DAO{
    some queries/inserts/deletes
}
//entity
@Entity
data class SomeEntity(
    val some:String
)

than you can use your database like:

val database=Room
    .databaseBuilder<JobsDatabase>("database path")
    .setDriver(BundledSQLiteDriver())
    .setQueryCoroutineContext(Dispatchers.IO)
    .build()
database.dao().insertSomething()
database.dao().querySomething()

Than build.

It will generate the code you want.

generated files

Reasons:
  • Whitelisted phrase (-1.5): you can use
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): I have a similar question
  • Low reputation (0.5):
Posted by: luckcc00