ssh2开发中属性可以为空问题
时间:2011-12-08
来源:互联网
我用了mysql数据库,然后在日期字段createTime中设置类型为timestamp,默认值CURRENT_TIMESTAMP,这样的话当我加入一条新纪录时mysql中该字段会自动生成时间,在纯jsp开发中我一直这么做的,没出现问题,然后当我用ssh2开发时当我保存新纪录时出现了下面异常:
Exception occurred inside getter of com.test.bean.News.createTime; nested exception is org.hibernate.PropertyAccessException: Exception occurred inside getter of com.test.bean.News.createTime
我hbm.xml中createTime是这样配置:
<property name="createTime" type="string" column="createTime">
</property>
News类中是这样:
private String createTime;
public String getCreateTime() {
return createTime.substring(0, 10);
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
我改如何正确配置<property>属性才能正确改正,之所以怀疑这是因为当我把上面那段配置去掉后就可以正常保存了,然而却出现在其他调用时间页面的地方时间显示不出来了
Exception occurred inside getter of com.test.bean.News.createTime; nested exception is org.hibernate.PropertyAccessException: Exception occurred inside getter of com.test.bean.News.createTime
我hbm.xml中createTime是这样配置:
<property name="createTime" type="string" column="createTime">
</property>
News类中是这样:
private String createTime;
public String getCreateTime() {
return createTime.substring(0, 10);
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
我改如何正确配置<property>属性才能正确改正,之所以怀疑这是因为当我把上面那段配置去掉后就可以正常保存了,然而却出现在其他调用时间页面的地方时间显示不出来了
作者: qizhiduoluo31 发布时间: 2011-12-08
属性为空 怎么个空法?
作者: hllfl 发布时间: 2011-12-08
就是我在新增新闻页面那里,即使我不用上传createTime属性值,也能正常保存一条新新闻,因为数据库里面时间字段是自己加入的,我只需要读出来就可以了,不用考虑自己写代码保存时间;但就像我上面所说的出现了问题
作者: qizhiduoluo31 发布时间: 2011-12-09
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28