2014-06-27 17:34 GMT+02:00 Ben Hood <[email protected]>:

> On Fri, Jun 27, 2014 at 4:19 PM, Lukas Eder <[email protected]> wrote:
> > Ah, maybe, you're looking for something like this?
> >
> > Optional<MyPrefixClass> result =
> > DSL.using(configuration)
> >    .select(A)
> >    .from(TABLE)
> >    .fetch()
> >
> >    .map(PREFIX_MAPPER)
> >
> >    .stream()
> >
> >    .findFirst();
>
> Very nice!
>
> I think I might just give up writing code myself and get you to write
> my app via the mailing list - do you also write mailing list parsers
> :-)
>

I think the usual Data Geekery rates are somewhere in the license text:
http://www.jooq.org/legal/licensing

;-)


> So for note, I ended up using this to get rid of the check for null:
>
> return db.execute(ctx ->
>         ctx.select().
>             from(PREFIXES).
>             where(PREFIXES.NATIONAL.eq(prefix + "")).
>             fetch().
>             map(PREFIX_MAPPER).
>             stream().
>             findFirst().
>             orElse(null)
>     );
>

Nice. I always like it when statements end with "OR ELSE!!!" ;-)

But I like that alternative of yours. It's a sign that some jOOQ features
can slowly transition towards more idiomatic Java 8 code. There was this
blog post here, that also showed how more complex transformations on jOOQ
records can be performed once the org.jooq.Result<R> is transformed into a
JDK Stream<R>:
http://blog.jooq.org/2014/04/11/java-8-friday-no-more-need-for-orms/

What's that db.execute thing, btw?

-- 
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.

Reply via email to