You're using quite a few vendor specific functions there, which are not supported out of the box in jOOQ. As always, when you run into this situation, you can roll your own support by using plain SQL templating, ideally by building your own library:
public static Field<Timestamp> fromUnixtime(Field<? extends Number> field) {
return field("from_unixtime({0})", SQLDataType.TIMESTAMP, field);
}
public static Field<Timestamp> convertTz(
Field<Timestamp> field,
Field<String> fromTz,
Field<String> toTz
) {
return field("convert_tz({0}, {1}, {2})", SQLDataType.TIMESTAMP, field, fromTz, toTz);
}
public static Field<String> sessionTimeZone() {
return field("@@session.time_zone", SQLDataType.VARCHAR);
}
Now, you can use it like this:
dsl.select(convertTz(
fromUnixtime(TRANSACTION.CREATION_DATE),
sessionTimeZone(),
inline("Europe/Berlin"))
)
.from(TRANSACTION)
.fetch();
Or, take it a step further and wrap all of these expressions in yet another auxiliary function, like this one:
public static Field<Timestamp> fromUnixtimeToBerlinTZ(Field<? extends Number> field) {
return convertTz(
fromUnixtime(TRANSACTION.CREATION_DATE),
sessionTimeZone(),
inline("Europe/Berlin")
);
}
All of these examples are assuming the usual static import:
import static org.jooq.impl.DSL.*;