简体   繁体   English

休眠:org.hibernate.PropertyAccessException:IllegalArgumentException

[英]Hibernate : org.hibernate.PropertyAccessException: IllegalArgumentException

I have a parent table (MHS_USER) and associated child table (GROUP) mapped with ManyToMany relation as follows (the relevant code below) 我有一个与ManyToMany关系映射的父表(MHS_USER)和关联的子表(GROUP),如下所示(下面的相关代码)

@Entity
@Table(name = "mhs_user")
public class MHSUser extends implements Comparable<User> {
        @ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
        @JoinTable(name = "user_group_rel", joinColumns = @JoinColumn(name = "mhs_user_id"), inverseJoinColumns = @JoinColumn(name = "group_id"))
        public List<Group> getGroups() {
                return groups;
        }
        public void setGroups(List<Group> groups) {
                this.groups = groups;
        }

}

In the above, mhs_user_id is the identity column in the MHS_USER table and grp_id is the identity key in the GROUP table. 在上面的代码中,mhs_user_id是MHS_USER表中的标识列,而grp_id是GROUP表中的标识键。 USER_GROUP_REL table is the join table that holds the relation between the two. USER_GROUP_REL表是保存两者之间关系的联接表。 When I persist a new User instance, it works as expected (by inserting a record into the parent table as well as the child table). 当我保留一个新的User实例时,它可以按预期工作(通过在父表和子表中插入一条记录)。 However, when I try updating any values to the User instance, PropertyAccessException is thrown. 但是,当我尝试将任何值更新为User实例时,都会引发PropertyAccessException。 Below is the selective stack trace 以下是选择性堆栈跟踪

------------------------------------------------------------------------------------------
[1/14/11 13:59:10:154 CST] 0000004b SystemErr     R Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of edu.mayo.hcdm.mhsr.businessobject.Group.id
        at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
        at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
………………………………………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………………………………………..
……………………………………………………………………………………………………………………………………………….. [1/14/11 13:59:10:154 CST] 0000004b SystemErr     R    ... 90 more
[1/14/11 13:59:10:154 CST] 0000004b SystemErr     R Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
------------------------------------------------------------------------------------------

It get's confusing as Hibernate throws an error that the "object is not an instance of declaring class" when searching for the group_id from the GROUP table only on updates. 当仅在更新时从GROUP表中搜索group_id时,Hibernate会抛出一个错误,即“对象不是声明类的实例”,这令人感到困惑。 I found a lot of threads online about it being a hibernate bug (am using Hibernate 3.3.1). 我在线上找到了很多线程,它们是一个休眠错误(我使用的是Hibernate 3.3.1)。 Has anyone encountered the same problem and if so, how did you end up solving it? 有人遇到过同样的问题吗?如果是,您最终是如何解决它的? Any input is highly appreciated. 高度赞赏任何输入。

确保groups列表中不包含Group以外的对象-这似乎是最明显的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hibernate Criteria - org.hibernate.PropertyAccessException:IllegalArgumentException - Hibernate Criteria - org.hibernate.PropertyAccessException: IllegalArgumentException org.hibernate.PropertyAccessException持续存在 - org.hibernate.PropertyAccessException on persist jComboBox给出org.hibernate.PropertyAccessException错误 - jComboBox giving org.hibernate.PropertyAccessException error 如何修复Spring Boot应用程序中的org.hibernate.PropertyAccessException:IllegalArgumentException异常 - How to fix org.hibernate.PropertyAccessException: IllegalArgumentException exception in spring boot application org.hibernate.PropertyAccessException:调用com.dms.model.Group.groupId的getter时发生了IllegalArgumentException - org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.dms.model.Group.groupId org.hibernate.PropertyAccessException:空值已分配给布尔类型的属性 - org.hibernate.PropertyAccessException: Null value was assigned to a property of boolean type org.hibernate.PropertyAccessException-如何从数据库中获取空值? - org.hibernate.PropertyAccessException - How to get a null value out of database? 为什么会出现org.hibernate.PropertyAccessException? - Why am I getting org.hibernate.PropertyAccessException? org.hibernate.PropertyAccessException,同时保持ManyToMany关系 - org.hibernate.PropertyAccessException while persisting ManyToMany relationship org.hibernate.PropertyAccessException:无法通过反射getter获取字段值 - org.hibernate.PropertyAccessException: could not get a field value by reflection getter of
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM