spring+hibernate问题之 BasicPropertyAccessor:

Hibernate: select orgnizatio0_.id as id1_, orgnizatio0_.name as name1_, orgnizatio0_.sn as sn1_, orgnizatio0_.description as descript4_1_, orgnizatio0_.pid as pid1_ from t_Orgnization orgnizatio0_ where orgnizatio0_.pid=?
14:54:21,265 ERROR BasicPropertyAccessor:167 - IllegalArgumentException in class: com.sbjt.oa.model.Orgnization, getter method of property: id
14:54:21,265 WARN AbstractExceptionHandler:95 - Unhandled exception
org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred calling getter of com.sbjt.oa.model.Orgnization.id; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.sbjt.oa.model.Orgnization.id
Caused by:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.sbjt.oa.model.Orgnization.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3257)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:2983)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:215)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:77)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1514)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1576)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)

原因:

传入参数类型与预期的类型不符

解决方法:

把方法:getHibernateTemplate().find(String hql, Object value)换成方法getHibernateTemplate().find(String hql),hql语句中的参数在外面赋值即可解决此异常

 

疑惑:

既然spring给提供了这个方法,为什么不能用啊,试过很多此了,还有setParameter方法,都会有这种错误,郁闷..........

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值