2017-12-13 14 views
0

java-1.8 jooq-3.10.0 SpringBoot-1.5.7はZonedDateTimeフィールドがDataTypeException

myCondition = create .select(... TABLE_AL.START_DATE.as("table_al_start_date"), TABLE_BR.START_DATE.as("table_br_start_date"))) .from(MAIN).innerJoin(TABLE_AL).onkey() .innerJoin(TABLE_BR).onkey() .where(DSL.trueCondition()); List<MyObject> myObjList = myCondition.fetch().into(MyObject.class)

class MyObject(){ ZonedDateTime tableAlStartDate; ZonedDateTime tableBrStartDate; ... }

table_al_start_datejava.time.ZonedDateTimeである私のオブジェクトは、いくつかのテーブルのフィールドを持っている

PostgreSQLtimestamp without time zone,nullable

会っていデータ型例外は行いますかrownは使用 .select(TABLE_A.START_DATE.as("table_a_start_date").cast(ZonedDateTime.class) もセッターsetTableAlStartDate(Long long)を追加しようとしたorg.jooq.exception.SQLDialectNotSupportedException: Type class java.time.ZonedDateTime is not supported in dialect null

を満たしますMyObject Caused by: org.jooq.exception.DataTypeException: Cannot convert from 1511971200000 (class java.lang.Long) to class java.time.ZonedDateTime at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:1169) at org.jooq.tools.Convert$ConvertAll.toDate(Convert.java:1121) at org.jooq.tools.Convert$ConvertAll.from(Convert.java:823)

場合にフェッチする場合、機能しません。

コンバータが見つかったcustom-bindings、カスタムコンバータを作成した後に何をする必要がありますか。 DataType<LocalDate> type = SQLDataType.DATE.asConvertedDataType(new LocalDateConverter());これは何ですか?

このZonedDateTimeフィールドとはどうすればよいですか?おかげさまで この良い習慣場合

答えて

0

わからない、私の作品:

myCondition = create 
    .select(,,, 
     DSL.field("table_al.start_date", SQLDataType.TIMESTAMP 
      .asConvertedDataType(ts2zonedConverter)) 
      .as("table_al_start_date"),,,, 
    .from(,,,); 

myConverter

public class TsZonedDateTimeConverter implements Converter<Timestamp, ZonedDateTime> { 
@Override public ZonedDateTime from(Timestamp t) { 
     return t == null ? null : t.toInstant().atZone(ZoneId.of("UTC")); 
    } 
@Override public Timestamp to(ZonedDateTime u) { 
     return u == null ? null : Timestamp.from(u.toInstant()); 
    } 
} 
関連する問題