On Friday, February 16, 2018 at 1:44:10 AM UTC-8, Lukas Eder wrote: > > > > 2018-02-16 10:21 GMT+01:00 Jason Bennett <[email protected] <javascript:>>: > >> I agree it makes sense, although it might be nice if jOOQ gave a >> specific error message when you alias some parts of the query, and not >> others. >> > > What specificity were you missing from *Ambiguous match found for id. > Both "child"."id" and "parent"."id" match" *? > >
Once I got that far, I agree the message was sufficient. Maybe this is my lack of understanding of jOOQ and aliasing, but I had a lot of struggles realizing that I needed to use the aliases instead of the table name in basically every place I might refer to the table. I guess that seems obvious now that I've written it. Not sure if jOOQ can throw an error if it sees aliases used in some places of the query, but not others. > fetchMap is ok, but the main issue is I have no key. The only way to get >> the keys is to iterate through the entrySet, which isn't the cleanest code. >> This is a lot easier in something like Kotlin, where you can give me a pair >> of the parent and a list of children. I suspect in Java, unless you want to >> have a jOOQ pair type, we're stuck with the map. >> > >> I did experiment with fetchParent and fetchChildren, although my main >> concern there is the second query. Still, that makes my code a lot cleaner, >> at the expense of slightly more DB time. >> > > That's never an option. > > Sorry, what is not an option? > > What does it mean that the "main issue is not having a key"? A key to > what? Why is a "pair" better than a Map.Entry? I'm assuming you're already > lost in your exploration of possibilities, describing your attempts to find > the way out of this "forest". It would be much better to reset your > expectations and start again from the ideal solution, display that, and > then ask - how can I best get there. Quite possibly, there is a jOOQ > feature I could show you, or a third party tool, or I could add a feature > request. > > Well, I'm certainly not suggesting that jOOQ should be Hibernate, or even myBatis - I understand that's not what it wants to be. I'm mainly suggesting that there be a way to fetch a query that assumes a single parent row (like fetchOne or fetchSingle), with an attached list of children. Pair is better than Map.Entry because there's no easy way to get at a single Map.Entry, without calling the iterator and taking the first one. That does work, it just looks messy. So, given a query that should return only a single "main" object, with one or more children, is there a good way for jOOQ to represent that, without returning a structure that assumes multiple "parent" objects the way that Map does. I hope that is a clearer expression of what I'm looking for. -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
