Hello,
> Sorry to necro this but I was wondering if it was possible to overrider the
> functionality of the default converters.
> For example with SQLServerDataType and DateTimeOffest, I'm wanting to
> convert the DateTimeOffset to a joda DateTime Object.
Unfortunately, this is currently not possible with jOOQ's code
generator. The only possible way to introduce converters is by using
matching table / column names, which you don't want to do...
I agree though, that it should be possible to configure this. I could
think of an enhancement to the code generation configuration's
<ForcedType/> definition. Something along these lines:
<complexType name="ForcedType">
<all>
<!-- The name of the type to be forced upon various artefacts -->
<element name="name" type="string" minOccurs="1" maxOccurs="1" />
<!--
A Java regular expression matching columns, parameters, attributes,
etc to be forced to have this type
-->
<element name="expressions" type="string" minOccurs="0" maxOccurs="1" />
<!--
A Java regular expression matching data types to be forced to
have this type
-->
<element name="types" type="string" minOccurs="0" maxOccurs="1" />
</all>
</complexType>
The added <types/> element would allow to supply a regular expression
such as VARCHAR(\(\d+\))? or in your case, DATETIMEOFFSET. As with
today's forced type feature, this would then refer to a converter
referenced from <name/>
Would that suit your needs?
I have registered #2352 to track this feature request:
https://github.com/jOOQ/jOOQ/issues/2352
> I like to leverage JOOQ's autoconversion but override one one type of the
> converter. I'd like to be able to do this in a generic fashion because I
> don't know the schema of the database I'm trying to access and it would be
> expensive to reiterate over the data to check for DateTimeOffset in the
> resultSet (JOOQ auto converts to Timestamp which loses the timezone
> information).
java.sql.Timestamp should be able to maintain timezone information.
Could this be a JDBC driver issue? Are you using jconn3 or jtds? How
would you properly deserialise DateTimeOffset through JDBC directly?
Using ResultSet.getString()?
Note, even if you'd apply the above converter, jOOQ would first use
ResultSet.getTimestamp() to deserialise DATETIMEOFFSET types. I'll
have to think about this when implementing #2352. It should be
possible to derive the "best" JDBC type from the converter,
directly...
Cheers
Lukas