Hooking POJOs
You already know that jOOQ can generate POJOs on our behalf and it can handle user-defined POJOs, too. Moreover, you saw a significant number of mappings of a jOOQ result into POJOs (typically, via fetchInto()
); therefore, this is not a brand new topic for you. However, in this section, let's take a step further and really focus on different types of POJOs that are supported by jOOQ.
If all we configure is <pojos>true</pojos>
(here, Maven), then jOOQ generates POJOs with private
fields, empty constructors, constructors with arguments, getters and setters, and toString()
. However, jOOQ can also handle a very simple user-defined POJO such as this one:
public class SimplestCustomer { public String customerName; public String customerPhone; }
Here is a query that populates this POJO:
List<SimplestCustomer> result = ctx.select( CUSTOMER.CUSTOMER_NAME, CUSTOMER.PHONE.as("customerPhone...