5

附加新备份的数据库后,出现异常:

Caused by: org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.mytest.User.setPrimaryAccount

在我的用户类中,我有这些字段:

...

    private boolean isPrimaryAccount;

    public boolean getPrimaryAccount() {
        return isPrimaryAccount;
    }

    public void setPrimaryAccount(boolean primaryAccount) {
        isPrimaryAccount = primaryAccount;
    }

...

而这里的异常引用,是从什么开始给出异常的?

4

1 回答 1

9

附加新备份的数据库后

我认为,您的数据库表中有可为空的列,并且您在持久类中使用原始类型 boolean(不能设置为 null)。我认为这就是您收到此异常的原因。

Hibernate 建议您:

我们建议您在持久类上声明一致命名的标识符属性,并使用可空(即非原始)类型。

将布尔值更改为布尔值,这可能会有所帮助...

于 2012-01-30T16:56:56.350 回答