我在mysql中添加一个键,并且设置默认值是current_timestamp,而且我在mysql中添加一条数据也能显示当前时间,但是我在hibernate中添加了一条记录在数据库里显示的是null值,这是怎么回事呢? hibernate 配置文件:
<property name="gdate" type="java.sql.Timestamp">
<column name="gdate" length="19" />
</property>
model类:
public Timestamp getGdate() {
return this.gdate;
}
public void setGdate(Timestamp gdate) {
this.gdate = gdate;
}
private Timestamp gdate;
难道是set方法null值覆盖了默认值?
<property name="gdate" type="java.sql.Timestamp">
<column name="gdate" length="19" />
</property>
model类:
public Timestamp getGdate() {
return this.gdate;
}
public void setGdate(Timestamp gdate) {
this.gdate = gdate;
}
private Timestamp gdate;
难道是set方法null值覆盖了默认值?
return this.gdate;
}
public void setGdate(Date gdate) {
this.gdate = gdate;
}
也可以javalinux.me