2
저는 Oracle에 ZonedDateTime을 지속하려고합니다. 날짜를 변환하기 위해 다음과 같이ZonedDateTime with Oracle
@Entity
@Table(name = "TESTTABLE")
public class Order {
private static final long serialVersionUID = 1L;
@Type(type = "uuid-binary")
@Column(name = "ID")
private UUID id;
@Column(name = "CREATE_DATE")
private ZonedDateTime createdOn;
..and so on.
나는 또한 컨버터를 가지고 : 다음은 내 도메인 엔티티 클래스입니다
@Converter(autoApply = true)
public class OracleZonedDateTimeSeriliazer implements AttributeConverter<ZonedDateTime,Date>{
@Override
public Date convertToDatabaseColumn(ZonedDateTime attribute) {
return attribute == null ? null : java.util.Date.from(attribute.withZoneSameInstant
(ZoneOffset.UTC).toInstant());
}
@Override
public ZonedDateTime convertToEntityAttribute(Date dbData) {
return dbData == null ? null : ZonedDateTime.ofInstant(dbData.toInstant(), DateUtils.getEasternZoneId());
}
}
나는 다음과 같은 스택 트레이스를 얻고이 엔티티 유지하려고 :
를2016-12-16 10:47:06,669 [main] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ORA-00932: inconsistent datatypes: expected DATE got BINARY
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement
누군가 내가 잘못하고있는 것을 도와 줄 수 있다면 많은 도움이 될 것입니다.
아마 java.util.Date 대신에'java.sql.Timestamp'로 변환 해주세요.'java.util.Date'는 JDBC API에서 지원되지 않으므로 변환기가 호출되지 않고 'ZonedDateTime'은 바이트에 "커스텀"자바 클래스로 직렬 처리됩니다. 당연히 'hibernate-java8'도 포함 할 수 있습니다. http://stackoverflow.com/a/33001846/5221149 – Andreas
"CREATE_DATE"의 DB-column-type은 무엇입니까? –
@MenoHochschild 그 DATE는 sql.Date – Gurkha