hibernate 问题 exception setting property with CGLIB

[url]http://cagataycivici.wordpress.com/2006/01/03/propertyaccessexception_exception_setting_property_with/[/url]
PropertyAccessException: exception setting property with CGLIB
I haven’t been writing about common hibernate exceptions for a while until yesterday; I got this error
我一直以来没有关于hibernbate 的异常信息的文字,直到昨天我遇到了一个错误如下:

PropertyAccessException: exception setting property with cglib

There are two reasons I’ve observed.
我分析有两个原因:
Incompatible types between the hibernate mapping and the model being mapped
在映射文件和被映射的模型之间有不匹配的类型信息

For example you have a Set of objects but in the mapping file this relation is mapped as a list. When hibernate tries to set the values in the db to the model, the exception will be thrown because mapping is incompatible. Solution is to make the model and the mapping compatible.

Mapping a primitive type to a nullable column
映射了一个私有类型的属性到一个null列中
This one is also a common mistake, the reason is again a compatibility issue, primitives cannot be null and when hibernate observes the value in the mapped column is null then it tries to set a null value to a primitive which is invalid.In order to overcome this error, you can either assign a default value to the primitive value in the code like 0 or change the primitive to a wrapper which means use Integer instead of int.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值