Reader small image

You're reading from  jOOQ Masterclass

Product typeBook
Published inAug 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781800566897
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Anghel Leonard
Anghel Leonard
author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard

Right arrow

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...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
jOOQ Masterclass
Published in: Aug 2022Publisher: PacktISBN-13: 9781800566897

Author (1)

author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard