Question

I've got a class set up kind of like this:

class ParentClass{
    // Some other fields
    Set<ChildClass> children
}

I'm wanting to use groovy.sql.Sql to keep the related ChildClass objects appropriately persisted in relationship to the ParentClass. I've used ORM tools like Hibernate before, and I'd rather stick to just using groovy.sql.Sql if at all possible.

I'm wondering if groovy.sql.Sql has any sort of convenience helpers for keeping child collections syncronized? I don't mind writing closures and whatnot to do a comparison of the "currently persisted" set vs the "newly persisted" set, to decide what to add and remove, but I was kind of hoping groovy already took care of that for me.

Was it helpful?

Solution

As far as I know groovy has no such mechanism. I suppose You write Your own DSL for that but I see it as rather complicated (and prone to DB scheme changes) and don't know if the game is worth the candle.

If You don't like using ORM tools (I also always hesitate to use them) maybe try something that isn't an ORM tool but helps to avoid plain SQL in groovy code: jOOQ (as far as I know there's no relationship handling in jOOQ). Haven't used it yet but still want to try.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top