hibernate数据库查询 除了fingALL()方法以外 其他方法都出现报错

问题描述

使用hibernate数据库查询除了fingALL()方法以外其他方法都出现以下报错很纠结啊以前不会啊Theserverencounteredaninternalerror()thatpreventeditfromfulfillingthisrequest.exceptionjava.lang.reflect.InvocationTargetExceptionsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)java.lang.reflect.Method.invoke(Method.java:597)com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept。。。。。省略一些rootcausejava.lang.NoSuchMethodError:antlr.collections.AST.getLine()Iorg.hibernate.hql.ast.HqlSqlWalker.generatePositionalParameter(HqlSqlWalker.java:896)org.hibernate.hql.antlr.HqlSqlBaseWalker.parameter(HqlSqlBaseWalker.java:4819)org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1373)org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4243)org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3725)org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1864)org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:818)org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:604)org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)com.hwadeecrm.dao.CrmuserDAO.findByProperty(CrmuserDAO.java:141)com.hwadeecrm.dao.CrmuserDAO.findByAuthorityId(CrmuserDAO.java:155)com.hwadeecrm.serviceImpl.CrmuserServiceImpl.findByUserName(CrmuserServiceImpl.java:58)com.hwadeecrm.action.CrmuserAction.searchCrmuser(CrmuserAction.java:96)sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)java.lang.reflect.Method.invoke(Method.java:597)com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)

解决方案

解决方案二:
最好吧HQL语句贴出来看看,光凭这个报错很难看出问题啊
解决方案三:
jar包冲突原因:项目里有这两个jar包产生了冲突所致:antlr-2.7.6.jar和anltr-2.7.2.jar。将anltr-2.7.2.jar包删除即可。
解决方案四:
publicListfindBySearchUserName(StringsearchString){log.debug("findingCrmuserinstancewithUserNamecontents:"+searchString);try{StringqueryString="fromCrmuserasmodelwheremodel.userNamelike:value";QueryqueryObject=getSession().createQuery(queryString);queryObject.setString("value","%"+searchString+"%");System.out.println("--------------d");returnqueryObject.list();}catch(RuntimeExceptionre){log.error("findbypropertynamefailed",re);throwre;}}这个自己写的System.out.println("--------------d");出不来就报这个错如果使用DAO里自带的方法如:(全都报错)publicListfindByProperty(StringpropertyName,Objectvalue){log.debug("findingCrmuserinstancewithproperty:"+propertyName+",value:"+value);try{StringqueryString="fromCrmuserasmodelwheremodel."+propertyName+"=?";QueryqueryObject=getSession().createQuery(queryString);queryObject.setParameter(0,value);returnqueryObject.list();}catch(RuntimeExceptionre){log.error("findbypropertynamefailed",re);throwre;}}publicListfindByWorkerId(ObjectworkerId){returnfindByProperty(WORKER_ID,workerId);}publicListfindByAuthorityId(ObjectauthorityId){returnfindByProperty(AUTHORITY_ID,authorityId);}publicListfindByUserName(ObjectuserName){returnfindByProperty(USER_NAME,userName);}只有findAll()和findById()方法可以正常运行
解决方案五:
是包的问题吗?我在运行的还有一个项目啊也是这样做的没有包冲突报错的问题啊
解决方案六:
StringqueryString="fromCrmuserasmodelwheremodel.userNamelike:value";貌似这句错了,模糊查询hql语句不是这样吧StringqueryString="fromCrmuserasmodelwheremodel.userNamelike'%"+value+"%'";
解决方案七:
十分感谢是Hibernate版本问题模糊查询格式改了就可用了可是DAO自带的方法依然用不了一调用就出错publicListfindByProperty(StringpropertyName,Objectvalue){log.debug("findingCrmuserinstancewithproperty:"+propertyName+",value:"+value);try{StringqueryString="fromCrmuserasmodelwheremodel."+propertyName+"=?";QueryqueryObject=getSession().createQuery(queryString);queryObject.setParameter(0,value);returnqueryObject.list();}catch(RuntimeExceptionre){log.error("findbypropertynamefailed",re);throwre;}}publicListfindByWorkerId(ObjectworkerId){returnfindByProperty(WORKER_ID,workerId);}publicListfindByAuthorityId(ObjectauthorityId){returnfindByProperty(AUTHORITY_ID,authorityId);}publicListfindByUserName(ObjectuserName){returnfindByProperty(USER_NAME,userName);}

时间: 2024-09-27 00:16:26

hibernate数据库查询 除了fingALL()方法以外 其他方法都出现报错的相关文章

php从数据库查询结果生成树形列表的方法_php技巧

本文实例讲述了php从数据库查询结果生成树形列表的方法.分享给大家供大家参考.具体分析如下: 本代码可以从数据库读取数据生成一个类似于windows的资源管理器的树形列表 <?php /* Here are the database definitions (for Solid) that i use in this code. * It should not be hard to adapt it to another database. */ /* CREATE TABLE dirent_t

SQLCE数据库,在插入了大128M数据的时候报错

问题描述 SQLCE数据库,在插入了大128M数据的时候报错 具体过程是这样的,我用VS2005平台的VB.NET语言开发WINCE5的项目,首先创建一个数据库(ABC.SDF),再用"CREATE TABLE"创建了31个"DAY1~DAY31"的表,并创建了索引,然后第隔200ms,用"INSERT INTO "按当前日期入对应的表格插入120BYTE的字符,一天大概增加48M,前几天都很正常,最近报了上述错误"The databa

反射中调用方法传入参数类型一样 却报错

问题描述 反射中调用方法传入参数类型一样 却报错 object obj = Activator.CreateInstance(objectType);// 创建实例 反射创建一个实例 MethodInfo methodInfo = obj.GetType().GetMethod("Parse"); //调用里面的Parse 方法 这个方法需要参数 List methodInfo.Invoke(obj, new object[]{items}); //items 是List类型的参数 ,

数据库导入-sql脚本insert语句过长,导入报错

问题描述 sql脚本insert语句过长,导入报错 今天在用mysql导入sql脚本时,报错"MySQL server has gone away",经检测,是"insert...value..."里数据过多导致不能插入.后修改配置文件: 1.tmp_table_size 2.max_allowed_packet 仍旧报同样的错.来位大神解决了吧,真揪心. ps:最好是通过调整mysql配置参数,因为sql不是本人写的.

继承EaseBaseActivity后onResume方法中 EaseUI.getInstance().getNotifier().reset();报错,求大神看是啥问题

问题描述 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.easemob.easeui.model.EaseNotifier.reset()' on a null object reference 解决方案 EaseUI.getInstance().getNotifier().reset();解决方案二:你解决了吗?

水晶报表调用export()方法导出pdf的时候,报错

问题描述 文件C:UsersAdministratorAppDataLocalTemptemp_f06b7300-5ac4-4f07-ad70-098d397bbdac{A6A94519-34EE-46F0-9718-A114AF472199}.rpt内出错:尚未执行操作.我用的是vb客户端调用的,在很久之前的电脑可以调用,在我自己的电脑不可以 解决方案 解决方案二: 解决方案三:引用1楼sinat_35256924的回复: 实现水晶报表导出pdf格式的代码:privatevoidpdfGene

请问下下面这个数据库的处理设置哪里改呢?为什么会报错啊

问题描述 <!--StartFragment --> 解决方案 Driver name错了,应该是:com.mysql.jdbc.DriverPS:你是不是发了两遍啊..

json 返回hibernate load查询数据出错

问题描述 json 返回hibernate load查询数据出错 我用get()方法查询出来的数据print到页面不会有错!但是用load()方法查询出来的数据print到页面是就出现错误!如果在实体中设置lazy=""false""也不会出错!哪位高手给说明一下原因, 解决方案 懒加载呗........ 解决方案二: 那怎么解决,不会是每一个实体中都设置lazy=""false""吧 解决方案三: 看下load和get的区别

oracle RMAN备份报错的诊断过程(四)继续清除数据库中僵死的会话

经过前面的努力,数据库中所有的JOB恢复正常,没有长时间持有锁的会话,事务视图中也没有长时间运行的事务: SQL> SELECT INSTANCE_NAME FROM V$INSTANCE; INSTANCE_NAME ---------------- tradedb1 已选择1行. SQL> SELECT SID, TYPE, ID1, ID2, LMODE, REQUEST, CTIME, BLOCK 2  FROM V$LOCK 3  WHERE CTIME > 86400 4