1
DATE 필드를 데이터베이스에서 읽을 때 해당 개체를 java.time.LocalDate
개체로 강제 변환 할 수있는 변환기를 만들었습니다. DATE에서 java.time.LocalDate까지 JPA 변환기가 Glassfish 4.1에 적용되지 않음
The object [3/16/17 12:00 AM], of class [class java.sql.Timestamp], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[startDate-->TEST_TABLE.START_DATE]] with descriptor [RelationalDescriptor(com.test.TestEntity --> [DatabaseTable(TEST_TABLE)])], could not be converted to [class [B].
TEST_TABLE
DATE
입니다 열
START_DATE
을 가지고 내 테이블입니다 : 내가 그렇게하려고 할 때, 그것은 나에게 오류를 제공합니다. 다음은 변환기입니다.
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.sql.Date;
import java.time.LocalDate;
@Converter(autoApply = true)
public class OracleLocalDateAttributeConverter implements AttributeConverter<LocalDate, Date> {
@Override
public Date convertToDatabaseColumn(LocalDate attribute) {
return (attribute != null ? Date.valueOf(attribute) : null);
}
@Override
public LocalDate convertToEntityAttribute(Date dbData) {
return (dbData != null ? dbData.toLocalDate() : null);
}
}
왜 내 열이 타임 스탬프라고 생각합니까? oracle의 모든 날짜가 java.sql.Timestamp
으로 강요 당합니까?