Am I doing anything wrong here? I created a role `...
# exposed
t
Am I doing anything wrong here? I created a role
Copy code
val id =  Roles.insertAndGetId { it[name] = ROLE_ADMIN;it[createdAt] = DateTime.now();it[updatedAt] = DateTime.now() }
Then any attempt to insert a user with the role like this:
Copy code
UserEntity.new {
                email = "<mailto:admin@test.com|admin@test.com>"
                roleId = id
                emailVerified = true
                password = 'password'
                createdAt = DateTime.now()
                updatedAt = DateTime.now()
            }
I get the following error:
INFO  Exposed - Transaction attempt #2 failed: Invalid argument value: java.io.NotSerializableException. Statement(s): null
I am calling both query in the same transaction{}
Okay I realized I was using
Column<T>
for the reference instead of
IdTable<T>
. Does it mean I can't use
Column<T>
to reference IdTables?
t
Could you provide the full sample?
t
Okay. So I have user table, having a reference to Role.id table like:
Copy code
object Users: LongIdTable("users"){
    ...
    val roleId = reference("role_id", Roles.id, ReferenceOption.CASCADE)
    ...
}
Where
Roles
is a
IntIdTable
. Trying to insert into user table throws
INFO  Exposed - Transaction attempt #2 failed: Invalid argument value: java.io.NotSerializableException. Statement(s): null
whether I use DSL or DAO. Changing the user table to:
Copy code
object Users: LongIdTable("users"){
    ...
    val roleId = reference("role_id", Roles, ReferenceOption.CASCADE)
    ...
}
solved the issue.
t
Maybe there is a bug, I’ll check it later. Thank you for a feedback