kurt_steiner
01/19/2024, 1:00 PMid
, the result is empty, you check my log
2024-01-19 20:52:01.413 [DefaultDispatcher-worker-2] DEBUG Exposed - DELETE FROM roles
2024-01-19 20:52:01.414 [DefaultDispatcher-worker-2] DEBUG Exposed - DELETE FROM userrole
2024-01-19 20:52:01.426 [DefaultDispatcher-worker-2] DEBUG Exposed - DELETE FROM users
2024-01-19 20:52:01.439 [DefaultDispatcher-worker-2] DEBUG Exposed - SELECT roles.id, roles."name" FROM roles WHERE roles."name" = 'user'
2024-01-19 20:52:01.443 [DefaultDispatcher-worker-2] DEBUG Exposed - INSERT INTO roles ("name") VALUES ('user')
2024-01-19 20:52:01.450 [DefaultDispatcher-worker-2] DEBUG Exposed - SELECT roles.id, roles."name" FROM roles WHERE roles.id = 3
Exception in thread "main" com.steiner.workbench.common.exception.TransactionException: there is an error in transaction
the TransactionException
is a custom exception, and it is thrown at
suspend fun insertOne(request: PostRoleRequest): Role {
return dbQuery {
val exists = Roles.select(Roles.name eq request.name).firstOrNull() != null
if (!exists) {
val id = Roles.insert {
it[name] = request.name
} get Roles.id
findOne(id.value) ?: throw TransactionException("there is an error in transaction")
} else {
throw BadRequestException("role name duplicate")
}
}
}
can you help me out? I don't know what's the matter with my code