Caused by: java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!

Caused by: java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:55)
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:61)
at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:397)
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:369)
at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:927)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)
at com.dtsz.model.base.GenericDaoImpl.query(GenericDaoImpl.java:1252)
at com.dtsz.model.service.jbpm.ReportJBPMRelationManager.getExeceRelationByTaskCodeReportUnit(ReportJBPMRelationManager.java:486)
at com.dtsz.model.service.jbpm.ReportJBPMRelationManager$$FastClassByCGLIB$$3a96e5f7.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at com.dtsz.model.service.jbpm.ReportJBPMRelationManager$$EnhancerByCGLIB$$49731912.getExeceRelationByTaskCodeReportUnit(<generated>)
at com.dtsz.view.bean.TaskAction.findExecedTask(TaskAction.java:2649)

... 20 more

报这个错的sql语句:

String queryString = " from ReportJBPMRelation R where R.thisTaskCode = ? and R.execedUserIDs like '%?%' and R.status = '0' order by R.thisDate desc";

Object[] params =  new Object[2];
params[0] = taskCode;
params[1] = userID;
reportJBPMRelations = reportJBPMRelationDao.query(queryString, params);


修改后:

String queryString = " from ReportJBPMRelation R where R.thisTaskCode = ? and R.execedUserIDs like '%"+userID+"%' and R.status = '0' order by R.thisDate desc";
reportJBPMRelations = reportJBPMRelationDao.query(queryString, taskCode);


问题发生的原因是:将HQL语句中''中的?没有解析成占位符,确解析成字符串了,又因为是模糊查询,所以只能这样。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值