Kotlin exposed relations.

Hi Guys, I’m developing a complete template for my projects that you found here https://github.com/CristianMG/Ktor-template, the problem is about relations in Kotlin exposed, I’m trying to define a relation between the user object and multimedia object which is an object uploaded which represents multimedia inside S3/Minio, is a relation inside user who contains the foreign key of multimedia, the goal is to have a table Multimedia which contains all object that s3/Minio contains.

In my UserEntity Dao, I have this code

var profileImage by MultimediaEntity optionalReferencedOn Users.profileImage

In my table descriptor I have this code

val profileImage = (uuid(“profile_image”).entityId()).references(Multimedia.id).nullable()
You can find the complete code here.

https://github.com/CristianMG/Ktor-template/blob/master/backend/src/main/kotlin/com/example/data/UserEntity.kt

When I try to create a new UserEntity with the reference to null because is optional, I obtain this error.

java.lang.IllegalStateException: Column and factory point to different tables

Any ideas/suggestions about how to achieve this behavior?

Great community thanks.

submitted by /u/StrawberryInternal23
[link] [comments]