I have jooq create TableImpl POJO name CONNECTOR with variable joda.time.DateTime
and jsonschema2pojo create POJO name JsonConnector with variable java.time.Instant
how to convert jooq select result fetch to jsonschema2pojo create obj
List <JsonConnector> list = ctx.select(
CONNECTOR.INT1,
CONNECTOR.STRING1,
CONNECTOR.STRING2,
CONNECTOR.STRING3,
CONNECTOR.STRING4,
CONNECTOR.JODA_TIME_DATETIME))
.from(CONNECTOR)
.fetchInto(JsonConnector.class);
jooq fetchInto jsonschema2pojo everything simple type convert is ok, but pojo type org.joda.time.DateTime to type java.time.Instant
that will throw exception org.jooq.exception.MappingException: An error ocurred when mapping record to class JsonConnector
how can I write function like
TableField<ConnectorRecord, Instant> convertDateTimeToInstant(TableField<ConnectorRecord, DateTime> datatimeField)
or something good method
Thanks
Register a global
ConverterProviderFor the particular use-case you have here, you can implement a
ConverterProviderthat is able to convert between these two data types.ConverterProvideris an SPI that allows to override the default data type conversions between two data types, such asDateTimeandInstant, in both directions.Roughly:
You then set that to your local or global
Configuration:Using a local ad-hoc converter
You can always attach a local ad-hoc converter to a field, effectively chaining converters