0
에 키로 java.time.LocalDateTime를 매핑 :최대 절전 모드 및 JPA 2.1 - 다음 열거는 도메인 모델 클래스에서 제공됩니다 java.util.Map
public enum OperationMode {
BATTERY_CHANGE_MODE,
PBP_MODE
}
는 또한 LocalDateTime 사이에 변환하는 AttributeConverter 정의
@ElementCollection
@MapKeyColumn(name = "time")
@Convert(converter = LocalDateTimeAttributeConverter.class)
// some annotations are missing here...
private Map<LocalDateTime, OperationMode> operationHistory;
: 나는 요소 컬렉션으로 java.utitl.Map에 대한 작업 매핑을 정의 할 필요가 Entity 클래스에서 타임 스탬프
@Converter
public class LocalDateTimeAttributeConverter implements AttributeConverter<LocalDateTime, Timestamp> {
@Override
public Timestamp convertToDatabaseColumn(LocalDateTime locDateTime) {
return (locDateTime == null ? null : Timestamp.valueOf(locDateTime));
}
@Override
public LocalDateTime convertToEntityAttribute(Timestamp sqlTimestamp) {
return (sqlTimestamp == null ? null : sqlTimestamp.toLocalDateTime());
}
}
0
이 방법을 사용하는 데 권장되는 방법은 무엇입니까?
@ElementCollection
@MapKeyColumn(name = "time")
@Convert(converter = LocalDateTimeAttributeConverter.class, attributeName = "key")
@Enumerated(EnumType.STRING)
private Map<LocalDateTime, OperationMode> operationHistory;
attributeName의'키'가 누락되었습니다