Java中的LocalDate将与JPA一起保留为Oracle中的日期

时间:2018-12-27 09:09:04

标签: java oracle hibernate jpa

我有一个如下的Policy类

@Entity

@Table(name =“ Policy”) 公共类政策{

private Long policyId;
private Long customerId;
private Long vehicleId;

@Convert(converter =LocalDateAttributeConverter.class)
private LocalDate policyStartDate;

@Convert(converter =LocalDateAttributeConverter.class)
private LocalDate policyEndDate;

@Id
@SequenceGenerator(name = "POLICYID_GEN", sequenceName = "policyId_seq", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "POLICYID_GEN")
@Column(name = "PolicyId")
public Long getPolicyId() {
    return policyId;
}

public void setPolicyId(Long policyId) {
    this.policyId = policyId;
}

@Column(name = "CustomerId")
public Long getCustomerId() {
    return customerId;
}

public void setCustomerId(Long customerId) {
    this.customerId = customerId;
}

@Column(name = "VehicleId")
public Long getVehicleId() {
    return vehicleId;
}

public void setVehicleId(Long vehicleId) {
    this.vehicleId = vehicleId;
}

@Column(name = "PolicyStartDate")
public LocalDate getPolicyStartDate() {
    return policyStartDate;
}

public void setPolicyStartDate(LocalDate policyStartDate) {
    this.policyStartDate = policyStartDate;
}

@Column(name = "PolicyEndDate")
public LocalDate getPolicyEndDate() {
    return policyEndDate;
}

public void setPolicyEndDate(LocalDate policyEndDate) {
    this.policyEndDate = policyEndDate;
}

我正在尝试使用JPA保持不变,但出现错误

  

休眠:从双重策略中选择policyId_seq.nextval   [policyId = 1006,customerId = 1,vehicleId = 1,policyStartDate = 2019-01-01,   policyEndDate = 2019-12-31]休眠:插入到Policy(CustomerId,   PolicyEndDate,PolicyStartDate,VehicleId,PolicyId)值(?,?,?,   ?,?)Dec 27,2018 2:25:25 PM   org.apache.catalina.core.StandardWrapperValve调用SEVERE:   带有路径的上下文中Servlet [PolicyController]的Servlet.service()   [/ InsurancePortal]引发异常[请求处理失败;嵌套的   例外是   org.springframework.dao.InvalidDataAccessResourceUsageException:   ORA-00932:数据类型不一致:预期的NUMBER获得了BINARY;的SQL   [n / a];嵌套异常为   org.hibernate.exception.SQLGrammarException:ORA-00932:不一致   数据类型:根本原因是预期的NUMBER得到了BINARY]   java.sql.SQLSyntaxErrorException:ORA-00932:数据类型不一致:   预期的NUMBER为BINARY

0 个答案:

没有答案