Fetching arrays, lists, sets, and maps
jOOQ reduces the code that is needed for fetching Result<Record> as an array, list, set, or map down to a simple call of its amazing API.
Fetching arrays
Fetching arrays can be done via a comprehensive set of jOOQ methods, including fetchArray() (along with its flavors), fetchOneArray(), fetchSingleArray(), fetchAnyArray(), fetchArrays(), and intoArray(). For instance, fetching all the DEPARTMENT fields as an array of Record can be done as follows:
Record[] result = ctx.select().from(DEPARTMENT).fetchArray();
In comparison, you can just fetch DEPARTMENT.NAME as a String[] as follows:
String[] result = ctx.select(DEPARTMENT.NAME).from(DEPARTMENT) Â Â Â .fetchArray(DEPARTMENT.NAME); String[] result = ctx.select(DEPARTMENT.NAME).from(DEPARTMENT) Â Â Â .collect(intoArray(new String[0]));
Alternatively, fetching all CUSTOMER.FIRST_BUY_DATE fields as an array of the YearMonth type can be done via fetchArray...