Eric Lopez
12/18/2024, 2:51 PMobject Views : Table() {
val id = varchar("id", 48)
val name = varchar("name", 128)
val owner = varchar("owner", 48)
val published = bool("published")
val game = text("game")
val featured = bool("featured")
override val primaryKey = PrimaryKey(id)
override val tableName: String = "views"
}
object CharactersView : Table() {
val characterId = long("character_id")
val viewId = varchar("view_id", 48).references(
Views.id, onDelete = ReferenceOption.CASCADE
)
override val tableName = "characters_view"
}
I'm getting this exception
Could not initialize class com.kos.views.repository.ViewsDatabaseRepository$CharactersView
everytime i try to use CharactersView. Works perfectly without the references.
Im using latest version (0.57)Daniel Pitts
12/18/2024, 3:22 PMChantal Loncle
12/18/2024, 3:51 PMTable.name
property instead:
object CharactersView : Table("characters_view") {
val characterId = long("character_id")
val viewId = varchar("view_id", 48).references(
Views.id, onDelete = ReferenceOption.CASCADE
)
}
Option 2
Move the override to the start of the block (at least before references()
is invoked):
object CharactersView : Table() {
override val tableName = "characters_view"
val characterId = long("character_id")
val viewId = varchar("view_id", 48).references(
Views.id, onDelete = ReferenceOption.CASCADE
)
}
I'll take a further look into how we can avoid this dependency on our end.Daniel Pitts
12/18/2024, 5:32 PMtableName
should be final rather than open then.Eric Lopez
12/18/2024, 5:46 PM