I am making database operations with JetBrains/Exposed. I was able to make use of the DAO approach to display data from the database on the TableView. It was quite challenging with the DSL approach.
After succeeding to display data, data binding was gone. My person class looks like this
class Person(id: EntityID<Int>) : IntEntity(id) {
companion object : IntEntityClass<Person>(Persons)
var name by Persons.name
var title by Persons.title
}
my view model looks like this
class PersonModel(person: Person?) : ViewModel() {
val name = bind {person?.observable(Person::name)}
val title = bind {person?.observable(Person::title)}
}
Each time I want to commit a change to the model I get
java.lang.IllegalStateException: No transaction in context.
I know this is because Person is used in the transaction context to perform Db queries.
I wish to know how I can bind data to view model given that I am using DAO API of JetBrains/Expose.
Thanks.