Does Spring Data JDBC support custom type converters

Viewed 4573

I have an entity that has a filed of type java.util.Date (or Timestamp, doesn't matter for the case).

public class StatusReason {
    @Column("SRN_ID")
    private Long id;
    @Column("SRN_CREATOR")
    private String creator;
    @Column("SRN_REASON")
    private String reason;
    @Column("SRN_STATUS")
    private String status;
    @Column("SRN_TIMESTAMP")
    private Date timestamp;
//getters, setters, etc...
}

The database is Oracle and the corresponding column is of type TIMESTAMP(6) WITH TIME ZONE

When I call any of the default findById or findAll methods of the repository I get: ConverterNotFoundException: No converter found capable of converting from type [oracle.sql.TIMESTAMPTZ] to type [java.util.Date].

I can create a custom RowMapper for the type and it will work fine. I was just wondering if it's possible to register a custom converter (in my case from oracle.sql.TIMESTAMPTZ to java.util.Date) so can still benefit from the default mapping and use the converter through the whole app.

1 Answers
Related