Hi Danilo, Sorry for the delay - thank you very much for your feedback and for your nice words!
Indeed, automation of fetching nested collection is something that's been on my mind for a long time. The SQL standard approach would be to make use of the MULTISET() operator - which is only really supported in Oracle. I haven't proven it yet, but I do hope that a variety of basic usage of MULTISET() can be emulated by running several queries. The relevant feature request is here: https://github.com/jOOQ/jOOQ/issues/3884 In PostgreSQL, emulation could be done via arrays of rows, i.e. by using something like array_agg(row(a, b, c)) Many other APIs (including JPA) have implemented tricks to enable foreign key / primary key navigation in a somewhat convenient way. I think they're not getting the big picture right. If jOOQ ever implements this, it'll be the SQL way, i.e. allowing users to create ad-hoc nested collections, not just nested collections for pre-defined relationships. (The latter of course will also be possible as it is a special case of the former). Thanks again for your feedback. PostgREST seems very nice. Quite possiby, it will be sufficient for your immediate use-cases where jOOQ is more overhead to fetch entities and nested entities. I will definitely think about this again to make jOOQ more competitive with tools like PostgREST in the future. Cheers, Lukas 2016-09-25 17:42 GMT+02:00 <[email protected]>: > Hello Lukas! > > First of all, congratulations (and thanks!) for your great work on JOOQ. > > One thing that would be a killer feature for many of the projects I have > been working on would be the ability to automatically retrieve/fetch and > nest/embed foreign entities (which have 1-N, N-1 or N-N relationships) in > Records and POJOs, similarly to what PostgREST does with Postgres ( > http://postgrest.com/api/reading/#embedding-foreign-entities) when it > returns JSON data for queries. > > E.g.: table "sessions" references table "speakers", and a SessionsRecord > for an existing Sessions row would be able to fetch SpeakersRecords for > every referenced Speakers row. Better yet, it could return a whole POJO > graph after a single method/fetch invocation. > > In order to see a working and somewhat equivalent example, just access the > following URL in your web browser > > > https://postgrest.herokuapp.com/sessions > > > and then compare the returned JSON to the one from this other URL > > > https://postgrest.herokuapp.com/sessions?select=*,speaker{*} > > > In fact, we are evaluating the use of PostgREST as a substitute for ORMs > and even JOOQ in some use cases mainly because of this feature. > > Thanks for your support! > > Danilo > > > > > On Wednesday, July 6, 2016 at 9:16:44 AM UTC-3, Lukas Eder wrote: >> >> Dear group, >> >> Part of jOOQ's success is its incredible amount of convenience methods >> that help reduce the boiler plate code at your side. We do this with >> massive overloading of API, for instance, when you work with fetch(), you >> may have noticed how many different types of fetch() there are in jOOQ. >> >> Just now, I have added yet another convenience method. A Converter >> constructor: >> https://github.com/jOOQ/jOOQ/issues/5398 >> >> It looks like this: >> >> static <T, U> Converter<T, U> of( >> Class<T> fromType, >> Class<U> toType, >> Function<? super T, ? extends U> from, >> Function<? super U, ? extends T> to >> ) { ... } >> >> And also: >> >> static <T, U> Converter<T, U> ofNullable( >> Class<T> fromType, >> Class<U> toType, >> Function<? super T, ? extends U> from, >> Function<? super U, ? extends T> to >> ) { >> return of( >> fromType, >> toType, >> t -> t == null ? null : from.apply(t), >> u -> u == null ? null : to.apply(u) >> ); >> } >> >> >> The above allows for creating simple ad-hoc, one-liner converters, such >> as: >> >> Converter<String, Integer> converter = >> Converter.ofNullable(String.class, Integer.class, Integer::parseInt, >> Object::toString); >> >> What's your biggest "itch" in the jOOQ API, which jOOQ could "scratch", >> or rather, make go away by adding new convenience API? >> >> All ideas welcome! >> Lukas >> > -- > 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. > -- 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.
