`
wxinpeng
  • 浏览: 582284 次
  • 性别: Icon_minigender_1
  • 来自: 青岛
社区版块
存档分类
最新评论

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方法,都会有这种错误,郁闷..........

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics