Custom data types and type binding
Roughly, when we want to map a type onto a non-standard JDBC type (a type that is not in org.jooq.impl.SQLDataType
), we need to focus on the org.jooq.Binding
API, as illustrated in the following code snippet:
public interface Binding<T, U> extends Serializable { ... }
For instance, binding the non-standard vendor-specific PostgreSQL HSTORE
data type to some Java data type (for instance, HSTORE
can be mapped quite conveniently to Java Map<String, String>
) needs to take advantage of the Binding
API, which contains the following methods (please read the comments):
// A converter that does the conversion between // the database type T and the user type U Converter<T, U> converter(); // A callback that generates the SQL string for bind values of // this binding type. Typically, just ?, but also ?::json, ... void sql(BindingSQLContext<U> ctx) throws SQLException; // Register a type for JDBC CallableStatement OUT parameters...