Allow Result.getValues() to accept a functional interface

14 views
Skip to first unread message

Daniele Antonini

unread,
Feb 12, 2020, 6:45:48 AM2/12/20
to jooq...@googlegroups.com
Hi,

not real problem, just a "Hey I was expeecting this method here but I haven't found", so is there any reason why jooq Result.getValues() do not accept a Functional interface?

Now I have to write:

dsl
.select(SYSTEM_PLUGIN.NAME)//
   
.from(SYSTEM_PLUGIN) //
   
.join(WORKGROUP_SYSTEM_PLUGIN)//
      .on(SYSTEM_PLUGIN.ID.eq(WORKGROUP_SYSTEM_PLUGIN.SYSTEM_PLUGIN_ID)) //
   
.where(WORKGROUP_SYSTEM_PLUGIN.WORKGROUP_ID.eq(workgroupId))
   
.fetch() //
   
.getValues(SYSTEM_PLUGIN.NAME)
   
.stream()
   
.map(name -> new SystemPlugin(name))
   
.collect(toList())

Instead of:

dsl
.select(SYSTEM_PLUGIN.NAME)//
   
.from(SYSTEM_PLUGIN) //
   
.join(WORKGROUP_SYSTEM_PLUGIN)//
      .on(SYSTEM_PLUGIN.ID.eq(WORKGROUP_SYSTEM_PLUGIN.SYSTEM_PLUGIN_ID)) //
   
.where(WORKGROUP_SYSTEM_PLUGIN.WORKGROUP_ID.eq(workgroupId))
   
.fetch() //
   
.getValues(SYSTEM_PLUGIN.NAME, name -> new SystemPlugin(name))

Am I asking too much ?

Cheers
--
Daniele

Lukas Eder

unread,
Feb 12, 2020, 7:58:49 AM2/12/20
to jOOQ User Group
Hi Daniele,

Thanks for your message.

From an API design perspective, I'm not convinced we need this overload. Think of the implications this would have on API surface, because we would have to add similar overloads everywhere for consistency reasons.

Having said so, you could use a converter on your NAME column, to make that column of type Field<SystemPlugin>.

Or you use the existing getValues(?, Converter) methods.

Or you could use 

fetch(r -> new SystemPlugin(r.get(SYSTEM_PLUGIN.name)));

I hope this helps,
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 jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAA1VVpGWStBoD%2BEdhyDWJGZU5xw7z6WZUvDP%3DC15u9HPph3dyg%40mail.gmail.com.

Daniele Antonini

unread,
Feb 12, 2020, 10:46:41 AM2/12/20
to jOOQ User Group
Thanks Lukas,

Il giorno mercoledì 12 febbraio 2020 13:58:49 UTC+1, Lukas Eder ha scritto:
Hi Daniele,

Thanks for your message.

From an API design perspective, I'm not convinced we need this overload. Think of the implications this would have on API surface, because we would have to add similar overloads everywhere for consistency reasons.
 That's why I wrote here. My use case is very simple and I thought I was missing some other "little" consideration.
 
Having said so, you could use a converter on your NAME column, to make that column of type Field<SystemPlugin>.
Yes I know but in this scenario I prefer to do not so
 
Or you use the existing getValues(?, Converter) methods.
In this case I don't want create a Converter


Or you could use
fetch(r -> new SystemPlugin(r.get(SYSTEM_PLUGIN.name)));
THIS is the solution I was looking for

I hope this helps,
Lukas
Thanks

To unsubscribe from this group and stop receiving emails from it, send an email to jooq...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages