Lukas/Thomas, Sometime ago I replied to this thread saying that it would be useful to be able to fetch the entire graph of related tables starting from a Record instance. I believe jOOQ is but a few steps away from some "ORMs" such as Bookshelf.js and Objection.js with regard to their "Data Mapper" capabilities, which is what I had in mind for jOOQ when I replied here (although I didn't know those ORMs at the time). Their beauty is in the way they only try to map tables instead of arbitrary entities and in the way SQL can be used at any time, even to specify which related tables should be fetched. jOOQ could provide all of that but with the beauty of its type safety.
Perhaps you would enjoy to see some examples of the usage of Objetion.js, such as in eager queries: http://vincit.github.io/objection.js/#eager-queries Kind regards, Danilo P.S.: Thanks for the great code snippets, Thomas! On Tue, Mar 21, 2017 at 2:36 PM, Lukas Eder <[email protected]> wrote: > Thank you very much for your feedback, Steinar. > I've cross linked your detailed suggestions from issue #5896 for better > referencing. > > Best Regards, > Lukas > > > 2017-03-21 13:35 GMT+01:00 <[email protected]>: > >> Hi >> >> As mentioned earlier, I really like the flexibility that .Net MicroORMs >> offer. This could be offered by JOOQ as well with more unmapper support: >> https://github.com/jOOQ/jOOQ/issues/5896 >> >> Currently I get by with some custom extensions: >> >> ColumnValueMap valMapper = ColumnValueMap.*create*("OWNERSYS.OWNER") >> .add(*field*("ID"), generatedSeqKey) >> .add(*field*("ENTITY_ID"), owner.getEntityId().Value) >> .add(*field*("NAME"), owner.getName()) >> .add(*field*("OFFICIAL_SOURCE"), owner.getOfficialSourceType(). >> getValue()) >> .add(*field*("BUSINESS_TYPE_ID"), owner.getBusinessType().getVal >> ue()) >> .add(*field*("OWNER_TYPE_ID"), owner.getOwnerType().getValue()) >> .add(*field*("VALID_FROM"), new >> Timestamp(owner.getValidFrom().toInstant().getEpochSecond() >> * 1000L)) >> .add(*field*("VALID_UNTIL"), new >> Timestamp(owner.getValidUntil().toInstant().getEpochSecond() >> * 1000L)) >> .add(*field*("REGISTERED_TIME"), new >> Timestamp(owner.getRegisteredTime().toInstant().getEpochSecond() * 1000L >> )); >> >> ctx.insertInto(*table*(valMapper.Table), valMapper.getColumns()).values >> (valMapper.getValues()).execute(); >> >> .. >> >> This is almost identical to what is already supported by JOOQ, the >> difference is that you get more compact code by mapping column and value in >> a single .add() method, thus the expression will become more compact, which >> again increases readability. >> >> >> >> An example of using the ColumnFieldMapper on simple types: >> >> .. >> >> Contact c = new Contact(0,"*t_at_t.no <http://t_at_t.no>*", "99221144", "Mr >> Anonymous"); >> ColumnFieldMap<Contact> mapper = new ColumnFieldMap<>(c, >> "OWNERSYS.CONTACT"); >> mapper.add(*field*("ID"), "Id").add(*field*("EMAIL"), "Email").add( >> *field*("PHONE"), "Phone").add(*field*("NAME"), "Name"); >> ctx.insertInto(*table*(mapper.Table), mapper.getColumns()).values(ma >> pper.getValues()).execute(); >> >> >> Having support for more unmapper features in JOOQ would be great, and it >> is ultra flexible. >> >> Thanks, >> Steinar. >> >> P.S I would not mind if the DAO support was removed. >> >> >> >> >> On Wednesday, July 6, 2016 at 2:16:44 PM UTC+2, 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. > -- 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.
