frellan

    frellan

    4 years ago
    Hello guys! I am planning on moving to this library for persistence, planning to use the DSL since I want more control of my sqls. Just a general question really, how do one handle nested relations with a dsl approach? One may want to have relations on the domain model but don’t load them all the time, so they would be null, so you would end up with a lot of stuff that is null, which is not nice. How do you guys do this? Remove the relations from the domain model and just keep the relations in the database, i.e dont do
    entity.otherEntites
    but rather
    DB.getOtherEntetiesFor(entity)
    or similar. How do you do this, need tips 🙂
    tapac

    tapac

    4 years ago
    I guess that you can use something like:
    class YourEntity {
       val otherEntities get() = DB.getOtherEntetiesFor(this)
    }
    frellan

    frellan

    4 years ago
    Yeah but then I do what a lazy ORM does and I’m back to not knowing when I talk to the DB. Plus I mix model and DB logic which is not very nice. But I guess there is not so many other ways to do it. How do you do this traditionally?
    tapac

    tapac

    4 years ago
    You asked about a DSL way, but if you work with Exposed DAO entities then you just have to use proper mapping. https://github.com/JetBrains/Exposed/wiki/DAO#simple-reference