https://kotlinlang.org logo
#exposed
Title
# exposed
v

v79

08/04/2018, 8:15 AM
Does anyone else's brain just hurt trying to build relationships in Exposed DAO? When to use
referrersOn
, when to use
referencedOn
? What's wrong with
hasOne
,
hasMany
? The DSL syntax is so much cleaner, but isn't really an ORM. Why a class and an object? And why do I only have to set up the relationship between two tables on three of these?
a

Allan Wang

08/05/2018, 2:52 AM
Referrers take on an attribute from another entity type, where that entity should match the current entity’s id. References take on an attribute from the current entity, and checks for a match to another entity’s id. The DAO sample shows this, though I do also find it confusing at times. I ultimately went with DAO because building all these relationships through the DSL involved a lot more code. Class is for the entity and object is for the table logic. I think this makes sense, and even if it were one class you’d need to have a companion object since tables are not part of an entity.
v

v79

08/05/2018, 7:06 AM
I am getting the hang of it. I've managed to make relationships between 5 tables. I'm sticking with DAO because I prefer its query syntax. I'm curious to compare a lines-of-code count with Exposed DAO, Exposed DSL, and something more traditional like Hibernate/JPA.
3 Views