Module org.jooq
Package org.jooq

Class Records

java.lang.Object
org.jooq.Records

public final class Records extends Object
Common utilities related to Record types and constructing RecordMapper.

The various mapping() methods can be used e.g. to map between Record types and constructors of known degree, such as in this example:

 record Actor (int id, String firstName, String lastName) {}

 List<Actor> actors =
 ctx.select(ACTOR.ID, ACTOR.FIRST_NAME, ACTOR.LAST_NAME)
    .from(ACTOR)
    .fetch(mapping(Actor::new));
 
Author:
Lukas Eder
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <E,​ R extends Record1<E>>
    Collector<R,​?,​E[]>
    intoArray​(E[] a)
    Create a collector that can collect Record1 resulting from a single column ResultQuery into an array of that column's type.
    static <E,​ R extends Record>
    Collector<R,​?,​E[]>
    intoArray​(E[] a, Function<? super R,​? extends E> function)
    Create a collector that can collect Record resulting from a ResultQuery into an array of a mapped type.
    static <E,​ R extends Record1<E>>
    Collector<R,​?,​E[]>
    intoArray​(Class<? extends E> componentType)
    Create a collector that can collect Record resulting from a ResultQuery into an array of a mapped type.
    static <E,​ R extends Record>
    Collector<R,​?,​E[]>
    intoArray​(Class<? extends E> componentType, Function<? super R,​? extends E> function)
    Create a collector that can collect Record resulting from a ResultQuery into an array of a mapped type.
    static <K,​ V,​ R extends Record2<K,​ V>>
    Collector<R,​?,​Map<K,​List<V>>>
    Create a collector that can collect Record2 resulting from a 2-column ResultQuery into a Map using the first column as key collecting values of the second column into a list of values.
    static <K,​ R extends Record>
    Collector<R,​?,​Map<K,​List<R>>>
    intoGroups​(Function<? super R,​? extends K> keyMapper)
    Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key collecting the records themselves into a list of values.
    static <K,​ V,​ R extends Record>
    Collector<R,​?,​Map<K,​List<V>>>
    intoGroups​(Function<? super R,​? extends K> keyMapper, Function<? super R,​? extends V> valueMapper)
    Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key collecting the result of another argument RecordMapper into a list of values.
    static <E,​ R extends Record1<E>>
    Collector<R,​?,​List<E>>
    Create a collector that can collect Record1 resulting from a single column ResultQuery into a List of that column's type.
    static <E,​ R extends Record>
    Collector<R,​?,​List<E>>
    intoList​(Function<? super R,​? extends E> function)
    Create a collector that can collect Record resulting from a ResultQuery into a List of a mapped type.
    static <K,​ V,​ R extends Record2<K,​ V>>
    Collector<R,​?,​Map<K,​V>>
    Create a collector that can collect Record2 resulting from a 2-column ResultQuery into a Map using the first column as key and the second column as value.
    static <K,​ R extends Record>
    Collector<R,​?,​Map<K,​R>>
    intoMap​(Function<? super R,​? extends K> keyMapper)
    Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key and the record itself as value.
    static <K,​ V,​ R extends Record>
    Collector<R,​?,​Map<K,​V>>
    intoMap​(Function<? super R,​? extends K> keyMapper, Function<? super R,​? extends V> valueMapper)
    Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key and the result of another argument RecordMapper as value.
    static <K,​ R extends Record>
    Collector<R,​?,​Map<K,​Result<R>>>
    intoResultGroups​(Function<? super R,​? extends K> keyMapper)
    Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key collecting the records themselves into a Result.
    static <K,​ V extends Record,​ R extends Record>
    Collector<R,​?,​Map<K,​Result<V>>>
    intoResultGroups​(Function<? super R,​? extends K> keyMapper, Function<? super R,​? extends V> valueMapper)
    Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key collecting the result of another argument RecordMapper into a Result of values.
    static <E,​ R extends Record1<E>>
    Collector<R,​?,​Set<E>>
    Create a collector that can collect Record1 resulting from a single column ResultQuery into a Set of that column's type.
    static <E,​ R extends Record>
    Collector<R,​?,​Set<E>>
    intoSet​(Function<? super R,​? extends E> function)
    Create a collector that can collect Record resulting from a ResultQuery into a Set of a mapped type.
    static <T1,​ R extends Record1<T1>,​ U>
    RecordMapper<R,​U>
    mapping​(Function1<? super T1,​? extends U> function)
    Create a RecordMapper that can map from Record1 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ R extends Record10<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10>,​ U>
    RecordMapper<R,​U>
    mapping​(Function10<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? extends U> function)
    Create a RecordMapper that can map from Record10 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ R extends Record11<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11>,​ U>
    RecordMapper<R,​U>
    mapping​(Function11<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? extends U> function)
    Create a RecordMapper that can map from Record11 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ R extends Record12<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12>,​ U>
    RecordMapper<R,​U>
    mapping​(Function12<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? extends U> function)
    Create a RecordMapper that can map from Record12 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ R extends Record13<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13>,​ U>
    RecordMapper<R,​U>
    mapping​(Function13<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? extends U> function)
    Create a RecordMapper that can map from Record13 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ R extends Record14<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14>,​ U>
    RecordMapper<R,​U>
    mapping​(Function14<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? extends U> function)
    Create a RecordMapper that can map from Record14 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ R extends Record15<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15>,​ U>
    RecordMapper<R,​U>
    mapping​(Function15<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? extends U> function)
    Create a RecordMapper that can map from Record15 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ R extends Record16<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16>,​ U>
    RecordMapper<R,​U>
    mapping​(Function16<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? extends U> function)
    Create a RecordMapper that can map from Record16 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ R extends Record17<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17>,​ U>
    RecordMapper<R,​U>
    mapping​(Function17<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? extends U> function)
    Create a RecordMapper that can map from Record17 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ R extends Record18<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18>,​ U>
    RecordMapper<R,​U>
    mapping​(Function18<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? extends U> function)
    Create a RecordMapper that can map from Record18 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ R extends Record19<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19>,​ U>
    RecordMapper<R,​U>
    mapping​(Function19<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? super T19,​? extends U> function)
    Create a RecordMapper that can map from Record19 to a user type in a type safe way.
    static <T1,​ T2,​ R extends Record2<T1,​ T2>,​ U>
    RecordMapper<R,​U>
    mapping​(Function2<? super T1,​? super T2,​? extends U> function)
    Create a RecordMapper that can map from Record2 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ R extends Record20<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20>,​ U>
    RecordMapper<R,​U>
    mapping​(Function20<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? super T19,​? super T20,​? extends U> function)
    Create a RecordMapper that can map from Record20 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ T21,​ R extends Record21<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ T21>,​ U>
    RecordMapper<R,​U>
    mapping​(Function21<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? super T19,​? super T20,​? super T21,​? extends U> function)
    Create a RecordMapper that can map from Record21 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ T21,​ T22,​ R extends Record22<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ T21,​ T22>,​ U>
    RecordMapper<R,​U>
    mapping​(Function22<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? super T19,​? super T20,​? super T21,​? super T22,​? extends U> function)
    Create a RecordMapper that can map from Record22 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ R extends Record3<T1,​ T2,​ T3>,​ U>
    RecordMapper<R,​U>
    mapping​(Function3<? super T1,​? super T2,​? super T3,​? extends U> function)
    Create a RecordMapper that can map from Record3 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ R extends Record4<T1,​ T2,​ T3,​ T4>,​ U>
    RecordMapper<R,​U>
    mapping​(Function4<? super T1,​? super T2,​? super T3,​? super T4,​? extends U> function)
    Create a RecordMapper that can map from Record4 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ R extends Record5<T1,​ T2,​ T3,​ T4,​ T5>,​ U>
    RecordMapper<R,​U>
    mapping​(Function5<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? extends U> function)
    Create a RecordMapper that can map from Record5 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ R extends Record6<T1,​ T2,​ T3,​ T4,​ T5,​ T6>,​ U>
    RecordMapper<R,​U>
    mapping​(Function6<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? extends U> function)
    Create a RecordMapper that can map from Record6 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ R extends Record7<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7>,​ U>
    RecordMapper<R,​U>
    mapping​(Function7<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? extends U> function)
    Create a RecordMapper that can map from Record7 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ R extends Record8<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8>,​ U>
    RecordMapper<R,​U>
    mapping​(Function8<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? extends U> function)
    Create a RecordMapper that can map from Record8 to a user type in a type safe way.
    static <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ R extends Record9<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9>,​ U>
    RecordMapper<R,​U>
    mapping​(Function9<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? extends U> function)
    Create a RecordMapper that can map from Record9 to a user type in a type safe way.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Records

      public Records()
  • Method Details

    • intoArray

      public static final <E,​ R extends Record1<E>> Collector<R,​?,​E[]> intoArray(E[] a)
      Create a collector that can collect Record1 resulting from a single column ResultQuery into an array of that column's type.

      For example:

       String[] titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .collect(intoArray(new String[0]));
       

      This is the same as the following, but allows for omitting repeating the BOOK.TITLE column:

       String[] titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .fetchArray(BOOK.TITLE);
       
    • intoArray

      public static final <E,​ R extends Record1<E>> Collector<R,​?,​E[]> intoArray(Class<? extends E> componentType)
      Create a collector that can collect Record resulting from a ResultQuery into an array of a mapped type.

      For example:

       String[] titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .collect(intoArray(new String[0], r -> r.get(BOOK.TITLE)));
       

      This is the same as the following:

       String[] titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .fetchArray(BOOK.TITLE);
       
    • intoArray

      public static final <E,​ R extends Record> Collector<R,​?,​E[]> intoArray(E[] a, Function<? super R,​? extends E> function)
      Create a collector that can collect Record resulting from a ResultQuery into an array of a mapped type.

      For example:

       String[] titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .collect(intoArray(new String[0], r -> r.get(BOOK.TITLE)));
       

      This is the same as the following:

       String[] titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .fetchArray(BOOK.TITLE);
       
    • intoArray

      public static final <E,​ R extends Record> Collector<R,​?,​E[]> intoArray(Class<? extends E> componentType, Function<? super R,​? extends E> function)
      Create a collector that can collect Record resulting from a ResultQuery into an array of a mapped type.

      For example:

       String[] titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .collect(intoArray(new String[0], r -> r.get(BOOK.TITLE)));
       

      This is the same as the following:

       String[] titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .fetchArray(BOOK.TITLE);
       
    • intoList

      public static final <E,​ R extends Record1<E>> Collector<R,​?,​List<E>> intoList()
      Create a collector that can collect Record1 resulting from a single column ResultQuery into a List of that column's type.

      For example:

       List<String> titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .collect(intoList());
       

      This is the same as the following, but allows for omitting repeating the BOOK.TITLE column:

       List<String> titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .fetch(BOOK.TITLE);
       
    • intoList

      public static final <E,​ R extends Record> Collector<R,​?,​List<E>> intoList(Function<? super R,​? extends E> function)
      Create a collector that can collect Record resulting from a ResultQuery into a List of a mapped type.

      For example:

       List<String> titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .collect(intoList(r -> r.get(BOOK.TITLE)));
       

      This is the same as the following:

       List<String> titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .fetch(BOOK.TITLE);
       
    • intoSet

      public static final <E,​ R extends Record1<E>> Collector<R,​?,​Set<E>> intoSet()
      Create a collector that can collect Record1 resulting from a single column ResultQuery into a Set of that column's type.

      For example:

       Set<String> titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .collect(intoSet());
       

      This is the same as the following, but allows for omitting repeating the BOOK.TITLE column:

       List<String> titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .fetchSet(BOOK.TITLE);
       
    • intoSet

      public static final <E,​ R extends Record> Collector<R,​?,​Set<E>> intoSet(Function<? super R,​? extends E> function)
      Create a collector that can collect Record resulting from a ResultQuery into a Set of a mapped type.

      For example:

       Set<String> titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .collect(intoSet(r -> r.get(BOOK.TITLE)));
       

      This is the same as the following:

       List<String> titles =
       ctx.select(BOOK.TITLE)
          .from(BOOK)
          .fetchSet(BOOK.TITLE);
       
    • intoMap

      public static final <K,​ V,​ R extends Record2<K,​ V>> Collector<R,​?,​Map<K,​V>> intoMap()
      Create a collector that can collect Record2 resulting from a 2-column ResultQuery into a Map using the first column as key and the second column as value.

      Collection throws InvalidResultException if a key is encountered more than once.

      For example:

       Map<Integer, String> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .collect(intoMap());
       

      This is the same as the following, but allows for omitting repeating the BOOK.ID and BOOK.TITLE columns:

       Map<Integer, String> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .fetchMap(BOOK.ID, BOOK.TITLE);
       
    • intoMap

      public static final <K,​ R extends Record> Collector<R,​?,​Map<K,​R>> intoMap(Function<? super R,​? extends K> keyMapper)
      Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key and the record itself as value.

      Collection throws InvalidResultException if a key is encountered more than once.

      For example:

       Map<Integer, Record2<Integer, String>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .collect(intoMap(r -> r.get(BOOK.ID)));
       

      This is the same as the following:

       Map<Integer, Record2<Integer, String>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .fetchMap(BOOK.ID);
       
    • intoMap

      public static final <K,​ V,​ R extends Record> Collector<R,​?,​Map<K,​V>> intoMap(Function<? super R,​? extends K> keyMapper, Function<? super R,​? extends V> valueMapper)
      Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key and the result of another argument RecordMapper as value.

      Collection throws InvalidResultException if a key is encountered more than once.

      For example:

       Map<Integer, String> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .collect(intoMap(r -> r.get(BOOK.ID), r -> r.get(BOOK.TITLE)));
       

      This is the same as the following:

       Map<Integer, String> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .fetchMap(BOOK.ID, BOOK.TITLE);
       
    • intoGroups

      public static final <K,​ V,​ R extends Record2<K,​ V>> Collector<R,​?,​Map<K,​List<V>>> intoGroups()
      Create a collector that can collect Record2 resulting from a 2-column ResultQuery into a Map using the first column as key collecting values of the second column into a list of values.

      For example:

       Map<Integer, List<String>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .collect(intoGroups());
       

      This is the same as the following, but allows for omitting repeating the BOOK.ID and BOOK.TITLE columns:

       Map<Integer, List<String>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .fetchGroups(BOOK.ID, BOOK.TITLE);
       
    • intoGroups

      public static final <K,​ R extends Record> Collector<R,​?,​Map<K,​List<R>>> intoGroups(Function<? super R,​? extends K> keyMapper)
      Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key collecting the records themselves into a list of values.

      For example:

       Map<Integer, List<Record2<Integer, String>>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .collect(intoGroups(r -> r.get(BOOK.ID)));
       

      This is the same as the following:

       Map<Integer, List<Record2<Integer, String>>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .fetchGroups(BOOK.ID);
       
    • intoGroups

      public static final <K,​ V,​ R extends Record> Collector<R,​?,​Map<K,​List<V>>> intoGroups(Function<? super R,​? extends K> keyMapper, Function<? super R,​? extends V> valueMapper)
      Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key collecting the result of another argument RecordMapper into a list of values.

      For example:

       Map<Integer, List<String>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .collect(intoGroups(r -> r.get(BOOK.ID), r -> r.get(BOOK.TITLE)));
       

      This is the same as the following:

       Map<Integer, List<String>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .fetchGroups(BOOK.ID, BOOK.TITLE);
       
    • intoResultGroups

      public static final <K,​ R extends Record> Collector<R,​?,​Map<K,​Result<R>>> intoResultGroups(Function<? super R,​? extends K> keyMapper)
      Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key collecting the records themselves into a Result.

      For example:

       Map<Integer, Result<Record2<Integer, String>>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .collect(intoResultGroups(r -> r.get(BOOK.ID)));
       

      This is the same as the following:

       Map<Integer, Result<Record2<Integer, String>>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .fetchGroups(BOOK.ID);
       
    • intoResultGroups

      public static final <K,​ V extends Record,​ R extends Record> Collector<R,​?,​Map<K,​Result<V>>> intoResultGroups(Function<? super R,​? extends K> keyMapper, Function<? super R,​? extends V> valueMapper)
      Create a collector that can collect Record resulting from a ResultQuery into a Map using the result of the argument RecordMapper as key collecting the result of another argument RecordMapper into a Result of values.

      For example:

       Map<Integer, Result<Record1<String>>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .collect(intoResultGroups(r -> r.get(BOOK.ID), r -> r.get(BOOK.TITLE)));
       

      This is the same as the following:

       Map<Integer, Result<Record1<String>>> books =
       ctx.select(BOOK.ID, BOOK.TITLE)
          .from(BOOK)
          .fetchGroups(BOOK.ID, BOOK.TITLE);
       
    • mapping

      public static final <T1,​ R extends Record1<T1>,​ U> RecordMapper<R,​U> mapping(Function1<? super T1,​? extends U> function)
      Create a RecordMapper that can map from Record1 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ R extends Record2<T1,​ T2>,​ U> RecordMapper<R,​U> mapping(Function2<? super T1,​? super T2,​? extends U> function)
      Create a RecordMapper that can map from Record2 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ R extends Record3<T1,​ T2,​ T3>,​ U> RecordMapper<R,​U> mapping(Function3<? super T1,​? super T2,​? super T3,​? extends U> function)
      Create a RecordMapper that can map from Record3 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ R extends Record4<T1,​ T2,​ T3,​ T4>,​ U> RecordMapper<R,​U> mapping(Function4<? super T1,​? super T2,​? super T3,​? super T4,​? extends U> function)
      Create a RecordMapper that can map from Record4 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ R extends Record5<T1,​ T2,​ T3,​ T4,​ T5>,​ U> RecordMapper<R,​U> mapping(Function5<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? extends U> function)
      Create a RecordMapper that can map from Record5 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ R extends Record6<T1,​ T2,​ T3,​ T4,​ T5,​ T6>,​ U> RecordMapper<R,​U> mapping(Function6<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? extends U> function)
      Create a RecordMapper that can map from Record6 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ R extends Record7<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7>,​ U> RecordMapper<R,​U> mapping(Function7<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? extends U> function)
      Create a RecordMapper that can map from Record7 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ R extends Record8<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8>,​ U> RecordMapper<R,​U> mapping(Function8<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? extends U> function)
      Create a RecordMapper that can map from Record8 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ R extends Record9<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9>,​ U> RecordMapper<R,​U> mapping(Function9<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? extends U> function)
      Create a RecordMapper that can map from Record9 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ R extends Record10<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10>,​ U> RecordMapper<R,​U> mapping(Function10<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? extends U> function)
      Create a RecordMapper that can map from Record10 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ R extends Record11<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11>,​ U> RecordMapper<R,​U> mapping(Function11<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? extends U> function)
      Create a RecordMapper that can map from Record11 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ R extends Record12<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12>,​ U> RecordMapper<R,​U> mapping(Function12<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? extends U> function)
      Create a RecordMapper that can map from Record12 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ R extends Record13<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13>,​ U> RecordMapper<R,​U> mapping(Function13<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? extends U> function)
      Create a RecordMapper that can map from Record13 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ R extends Record14<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14>,​ U> RecordMapper<R,​U> mapping(Function14<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? extends U> function)
      Create a RecordMapper that can map from Record14 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ R extends Record15<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15>,​ U> RecordMapper<R,​U> mapping(Function15<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? extends U> function)
      Create a RecordMapper that can map from Record15 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ R extends Record16<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16>,​ U> RecordMapper<R,​U> mapping(Function16<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? extends U> function)
      Create a RecordMapper that can map from Record16 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ R extends Record17<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17>,​ U> RecordMapper<R,​U> mapping(Function17<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? extends U> function)
      Create a RecordMapper that can map from Record17 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ R extends Record18<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18>,​ U> RecordMapper<R,​U> mapping(Function18<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? extends U> function)
      Create a RecordMapper that can map from Record18 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ R extends Record19<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19>,​ U> RecordMapper<R,​U> mapping(Function19<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? super T19,​? extends U> function)
      Create a RecordMapper that can map from Record19 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ R extends Record20<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20>,​ U> RecordMapper<R,​U> mapping(Function20<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? super T19,​? super T20,​? extends U> function)
      Create a RecordMapper that can map from Record20 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ T21,​ R extends Record21<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ T21>,​ U> RecordMapper<R,​U> mapping(Function21<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? super T19,​? super T20,​? super T21,​? extends U> function)
      Create a RecordMapper that can map from Record21 to a user type in a type safe way.
    • mapping

      public static final <T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ T21,​ T22,​ R extends Record22<T1,​ T2,​ T3,​ T4,​ T5,​ T6,​ T7,​ T8,​ T9,​ T10,​ T11,​ T12,​ T13,​ T14,​ T15,​ T16,​ T17,​ T18,​ T19,​ T20,​ T21,​ T22>,​ U> RecordMapper<R,​U> mapping(Function22<? super T1,​? super T2,​? super T3,​? super T4,​? super T5,​? super T6,​? super T7,​? super T8,​? super T9,​? super T10,​? super T11,​? super T12,​? super T13,​? super T14,​? super T15,​? super T16,​? super T17,​? super T18,​? super T19,​? super T20,​? super T21,​? super T22,​? extends U> function)
      Create a RecordMapper that can map from Record22 to a user type in a type safe way.