You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
object Cards : IntIdTable() {
enumclassIssuer {
ISSUER,
OTHER
}
val holder = reference("holder", Customers)
val number = varchar("number", 255)
val issuer = customEnumeration(
"issuer",
"ENUM('ISSUER', 'OTHER')",
{ Issuer.values()[it asInt] },
{ it.name }
)
}
classCardEntity(id:EntityID<Int>) : IntEntity(id) {
companionobject:IntEntityClass<CardEntity>(Cards)
var number by Cards.number
var customer by CustomerEntity referencedOn Cards.holder
var issuer by Cards.issuer
funtoDomain(): Card {
returnCard(
id = id.value,
number = number,
issuer = issuer.name,
holder = customer.id.value
)
}
}
I get a ClassCastException stating data.card.Cards$Issuer cannot be cast to java.lang.Integer when the toDomain() function tries to read the issuer.name
The entry in the database gets created, and all subsequent fetches and uses of toDomain() work fine. It's seems that it's only when using the Entity returned by the .new { ... } block that this occurs. Any ideas?
as my fromDb function to make things work, but that's pretty hacky...
The text was updated successfully, but these errors were encountered:
carterhudson
changed the title
Accessing enum field in entity created using EntityClass.new causes ClassCastException
Accessing enum field in Entity created using EntityClass.new causes ClassCastException
Jan 9, 2019
When I'm creating such an entity, everything is fine, but when I'm trying to update it , I get the same ClassCastException stating java.lang.String cannot be cast to java.lang.Enum.
I've got the following:
When I do the following:
I get a
ClassCastException
statingdata.card.Cards$Issuer cannot be cast to java.lang.Integer
when thetoDomain()
function tries to read theissuer.name
The entry in the database gets created, and all subsequent fetches and uses of
toDomain()
work fine. It's seems that it's only when using theEntity
returned by the.new { ... }
block that this occurs. Any ideas?Edit:
As a workaround, I can supply
as my
fromDb
function to make things work, but that's pretty hacky...The text was updated successfully, but these errors were encountered: