tjohnn
06/16/2019, 3:11 PMval 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:
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
tjohnn
06/16/2019, 3:14 PMtjohnn
06/16/2019, 8:04 PMColumn<T>
for the reference instead of IdTable<T>
. Does it mean I can't use Column<T>
to reference IdTables?tapac
06/17/2019, 2:55 PMtjohnn
06/17/2019, 7:09 PMobject 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:
object Users: LongIdTable("users"){
...
val roleId = reference("role_id", Roles, ReferenceOption.CASCADE)
...
}
solved the issue.tapac
06/18/2019, 9:45 PM