org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.catablog.entity.IdEntity.entityId
来源:互联网 发布:网络文明主题班会ppt 编辑:程序博客网 时间:2024/06/04 19:58
尝试做一个SSH+spring security+blazeDS+flex的例子,修改用户信息的时候报了这么个怪异常
- org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.catablog.entity.IdEntity.entityId
- at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195) [hibernate-core-3.3.1.GA.jar:3.3.1.GA]
- at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:206) [hibernate-core-3.3.1.GA.jar:3.3.1.GA]
- .....
- Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@156f770
- ......
我操作的用户类定义如下
- @Entity
- //表名与类名不相同时重新定义表名.
- @Table(name = "USERS")
- //默认的缓存策略.
- @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
- public class User extends IdEntity {
- private String loginName;
- private String password; //为简化演示,使用明文保存密码.
- private String name;
- private String email;
- private Set<Role> roles = new LinkedHashSet<Role>(); //有序的关联对象集合.
- public String getLoginName() {
- return loginName;
- }
- public void setLoginName(String loginName) {
- this.loginName = loginName;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- @Fetch(FetchMode.SUBSELECT)
- @LazyCollection(LazyCollectionOption.FALSE)
- @ManyToMany
- //多对多定义.
- @JoinTable(name = "USERS_ROLES", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") })
- //集合按id排序.
- @OrderBy("entityId")
- //集合中对象的id的缓存.
- @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
- public Set<Role> getRoles() {
- return roles;
- }
- public void setRoles(Set<Role> roles) {
- this.roles = roles;
- }
- //非持久化属性.
- @Transient
- public String getRoleNames() throws Exception {
- return ReflectionUtils.fetchElementPropertyToString(roles, "name", ", ");
- }
- //非持久化属性.
- @Transient
- @SuppressWarnings("unchecked")
- public List<Long> getRoleIds() throws Exception {
- return ReflectionUtils.fetchElementPropertyToList(roles, "id");
- }
- }
entityId是我所有VO的公共父类,把ID的定义抽象出来了,从上面的异常消息可以看出是参数类型转换的时候报了类型转换非法异常,抛异常的是Hibernate的BasicPropertyAccessor,这可是Hibernate的基本组件,我在修改用户信息之前就已经查询过一次了,如果是我的entityId的类型有问题,那查询的时候就会调用BasicPropertyAccessor的get方法,那个时候就该报错了,也不该撑到这会儿。Debug了一下才发现User实例里的Roles集合里面全是ASObject?!怪不得,ASObject当然没有getter setter了。
刚开始纳闷儿怎么我的actionScript User类传到java这边就能转成对应的User类,User里的Role集合一过来就变成了ASObject?后来才明白,ActionScript不支持泛型的,Role类放进User里的Roles ArrayCollection的时候类型就没了,传到java那边儿当然识别不出Role的类型,就只能用ASObject替代了,这还真是个问题,延迟加载已经够让我头大的了,这个怎么说也得搞定!
- org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.catablog.entity.IdEntity.entityId
- org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of
- org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com
- Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling se
- Exception in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of
- org.hibernate.PropertyAccessException: Exception occurred inside getter of com.sanxiau.entity.User.p
- org.hibernate.PropertyAccessException: IllegalArgumentException occurred while
- org.hibernate.PropertyAccessException: Exception occurred inside getter of ******——【hibernate 日常错误】
- org.hibernate.PropertyAccessException: Exception occurred inside setter of 错误解释
- 错误提示: IllegalArgumentException occurred calling getter of *
- 错误解决:IllegalArgumentException occurred calling getter of *
- org.hibernate.PropertyAccessException: IllegalArgumentException(已解决)
- 解决错误IllegalArgumentException occurred calling getter of cn.chengtech.ms.common.entity.BaseModel.id
- org.hibernate.propertyaccessexception could not get a field value by reflection getter of
- org.hibernate.PropertyAccessException:
- org.hibernate.PropertyAccessException
- 【hibernate映射问题】IllegalArgumentException occurred while calling setter of
- IllegalArgumentException occurred while calling setter of
- Java中文乱码问题的解决方案
- SWT(JFace)体验之Canvas(画布)
- 关于CPU时间片轮询的一点发现
- 关于C#学籍管理项目控制台的问题
- javascript方向键使用
- org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.catablog.entity.IdEntity.entityId
- JSTL核心标签库
- C#.Net中WinForm采用Active Directory进行身份认证
- FPDF中文应用攻略
- 设计模式2:Factory Method Pattern(工厂方法模式)
- 【下载】可以免费生成PDF文件的PHP类——FPDF
- 获得某个日期当月的最后一天和某一日
- 时间脚本
- RADIO BUTTON group