'lo all,

I was wondering if it was possible to specify a mapping function on a 
`select()` prior to completing the `where` clause etc.

I have a bunch of code currently like:

```java
public Optional<Foo> findFoos() {
  return Optional.fromNullable(dslContext.select(Foo.FIELD1, Foo.FIELD2)
                                         .from(Foo.FOO_TABLE
                                         .where(Foo.FIELD1.eq(.....))
                                         .fetchOne(FOO_RECORD_MAPPER)));
}

```

where I have several different variants, that only vary by the where clause. In 
this code, I've extracted `FOO_RECORD_MAPPER` out, but as the base query and 
field count increases, the code starts to look ugly in java lang generics ( 
it's now a `Record11<.....>` ).

Ideally I'd love to be able to refactor this somehow to read more like:

```java
private SelectJoinStep<Foo> findBaseFoo() {
  return dslContext.select(Foo.FIELD1, Foo.FIELD2)
                   .from(Foo.FOO_TABLE
                   .map(FOO_RECORD_MAPPER));
}

public Optional<Foo> findFoos() {
  return findBaseFoo().where(Foo.FIELD1.eq(.....))
                      .fetchOne());

```

Where I could then inline `FOO_RECORD_MAPPER` into `findBaseFoo` without 
exposing all the types ( via lambda syntax ) but it would also clean up the 
code more.

However, it doesn't appear I can do anything like this currently? Or am I 
missing something? A variant of `select()` maybe?

Mark 

-- 
Mark Derricutt
http://www.theoryinpractice.net
http://www.chaliceofblood.net
http://plus.google.com/+MarkDerricutt
http://twitter.com/talios
http://facebook.com/mderricutt

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

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to