https://kotlinlang.org logo
p

paulex

01/08/2020, 12:18 PM
Copy code
override fun modify(item: User): CompletionStage<User> {
    return supplyAsync {
        transaction {
            Users.update({ Users.id eq item.id }) {
                it[name] = item.name
                it[gender] = item.gender
                it[first_name] = item.firstName;
            }
        }
    }.thenApply { return@thenApply item }
}
Is there a way to simplify an update transaction on object properties, i feel it is repetitive to keep on writing : it[name] = item.name it[gender] = item.gender ?
a

adamd

01/08/2020, 12:26 PM
s

spand

01/08/2020, 12:28 PM
I think you want to use https://github.com/JetBrains/Exposed#dao-sample instead of the DSL variant
p

paulex

01/08/2020, 10:09 PM
@adamd Thanks, i think that library solves the problem i explained, however i'm currently not keen on using a library for this at the moment, but it's worth knowing there is a library that solves this. Thanks
👍 1
2 Views