浏览 4629 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2003-09-19
public setXXX(int a) { } 我猜想是在创建对象时错误,一种解决方法时将没有信息的这些整型字段补零,我试验过,没有问题。如果我不想使用这种方法,还有其他解决方法吗?最好时hibernate自己提供的。 我做了测试,如果我使用hibernate来创建对象,并不对这些对象赋值,系统自动补零。 多多希望高手指点。谢谢。 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2003-09-19
仔细看看这里,有解决你的问题的办法。
http://hibernate.fankai.com/viewtopic.php?t=260 |
|
返回顶楼 | |
发表时间:2003-09-20
我找到答案了,在hibernate 的FAQ中
Hibernate throws a PropertyAccessException or NullPointerException when I load or query an object! A PropertyAccessException often occurs when the object being passed to the setter method is of the wrong type. Check your type mappings for the offending property. (To see exactly which property was the problem, you might need to disable the CGLIB reflection optimizer.) However, the most common cause of this problem is that Hibernate attempted to assign null to a property of primitive type. If your object has a primitive-type property mapped to a nullable database column then you will need to use a Hibernate custom type to assign a sensible default (primitive) value for the case of a null column value. A better solution is usually to use a wrapper type for the Java property. 多谢斑竹的回答,谢谢 |
|
返回顶楼 | |