minivac
08/11/2024, 6:12 PMload that looks like this
val theRef by AnotherEntity referrersOn AnotherEntityTable.someID
end ups here with a distinctRefIds that is of type DaoEntityID but the column type from refColumn is uuid (in this case a custom kind of UUID, but that doesn't seem to be the problem) and as expected, the casting crashes
class org.jetbrains.exposed.dao.DaoEntityID cannot be cast to class the.custom.IDChantal Loncle
08/12/2024, 2:20 AMAnotherEntityTable.someID is defined something like:
val someID: Column<UUID> = uuid("some_id").references(OtherTable.id)
Or is the column defined as:
val someID: Column<EntityID<UUID>> = reference("some_id", OtherTable)minivac
08/12/2024, 7:24 AMobject AnotherTable : (...)
val mainTableID = registerColumn<UUID>("main_table_id", UUIDColumnType()).references(MainTable.id)
}minivac
08/12/2024, 7:26 AMProject and the N table is Member, and member has a row val projectID = registerColumn<UUID>(...).references(ProjectTable.id)minivac
08/12/2024, 7:27 AMMemberEntity I use
val project by ProjectEntity referencedOn MemberTable.projectID ,
and that works if accessing it normally as a reference but crashes with the load functionminivac
08/12/2024, 7:30 AMDaoEntityID is not castable to a UUID or whatever the actual type of the column isminivac
08/12/2024, 2:30 PMProject) is defined like your second option
class ProjectTable: IdTable<UUID> {
override val id: Column<EntityID<UUID>> = (...).entityId()
}
class MemberTable: IdTable<UUID> {
val projectID =registerColumn("project_id", ...)
.references(ProjectTable.id)
}Chantal Loncle
08/13/2024, 1:03 PMColumn.references() is being used to define the referencing column instead of reference(). So the parent is of type EntityID<UUID> as expected, but the child column is then of type UUID, and the DAO referential logic was set up to expect that referencing columns would always be storing the same type.
I'm able to get the exception when eager loading referrersOn, as you mentioned in your first message, and a fix is done.
But I'm not getting any issue with referencedOn like in your later messages. Was that a typo? You previously reported the issue with referencedOn and we pushed fixes for it (both lazy and eager loaded).minivac
08/13/2024, 1:56 PMreferrersOn, it was a typoChantal Loncle
08/13/2024, 2:11 PMbackReferencedOn in the event you end up using it too.