简体   繁体   English

休眠时的映射时间戳

[英]Mapping timestamp in hibernate

I am new to hibernate, and in my project I need to insert date and time into a column of type TIMESTAMP. 我是休眠的新手,在我的项目中,我需要将日期和时间插入TIMESTAMP类型的列中。 PFB the entity class. PFB实体类。

private Timestamp curdate; 私人时间戳记;

@Column(name = "UCM_DATE")
public Timestamp getCurdate() {
    return curdate;
}

public void setCurdate(Timestamp curdate) {
    this.curdate = curdate;
}

I am getting the following error when i try to run the code, even without providing values to the above field. 我尝试运行代码时遇到以下错误,即使没有为上述字段提供值也是如此。 ORA-00932: inconsistent datatypes: expected NUMBER got BINARY ORA-00932:数据类型不一致:预期的数字为BINARY

You can use java Date type like this: 您可以使用如下所示的Java Date类型:

@Column(name = "UCM_DATE")
@Temporal(TemporalType.TIMESTAMP)
public Date getCurdate() {
    return curdate;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM