异常消息如下所示:
org.hibernate.QueryException: could not resolve property: task_no of: edu.cust.entity.Task
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.entity.BasicEntityPersister.getSubclassPropertyTableNumber(BasicEntityPersister.java:1111)
at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:31)
at org.hibernate.persister.entity.BasicEntityPersister.toColumns(BasicEntityPersister.java:1086)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:403)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:369)
at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:42)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:314)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1303)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at edu.cust.dao.TaskDao.searchTask(TaskDao.java:129)
at edu.cust.struts.action.SearchTaskFuelAction.execute(SearchTaskFuelAction.java:69)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
这里,关键是“task_no of: edu.cust.entity.Task”,task_no为数据库中表的字段,异常时说在查询的时候无法解析这个字段,也就是说这个字段是错误的。
由于Eclipse能够进行Hibernate映射,并自动生成持久化类和对应的配置文件,对于类似于task_no中带有下划线的字段,则自动将下划线去掉,task_no在持久化类中对应属性为taskNo,所以,在Dao中编写查询的方法中,必须写成
criteria.add(Restrictions.eq("taskNo",task.getTaskNo()));
这里eq()方法的第一个参数对应于持久化类中的属性名称,如果使用下面:
criteria.add(Restrictions.eq("task_no",task.getTaskNo()));
就可能发生上面的异常,千万要小心。
一般地,如果涉及到属性类型无法解析的异常,可能出现问题的地方有:
数据库字段与持久化类映射文件,以及持久化类文件中属性名称或者类型可能不相匹配;
持久化类映射文件中属性类型可能有问题,比如,如果使用Java类型,注意大写(如type="java.lang.String"),如果使用Hibernate类型,使用小写(如type="string")。
分享到:
相关推荐
QueryException: could not resolve property 当执行HQL查询或criteria查询时,如果指定的属性名在目标类中不存在,或者属性路径有误,就会抛出此异常。例如,正确的查询可能是`from Category category where ...
按官方配置好了 developer.... Could not resolve com.huawei.agconnect 解决方法:把相应的插件用本地化安装 agconnect-crash-symbol-lib-1.6.1.300.jar agconnect-apms-plugin-1.6.1.300.jar agcp-1.6.1.300.jar。
hive 开发UDF 使用maven工程 引发jar包缺失 hive 开发UDF 使用maven工程 引发jar包缺失
`org.hibernate.QueryException: could not resolve property: isStudent of: com.zluo.hibernate.po.User [from com.zluo.hibernate.po.User u where u.isStudent = ?]` 当时就在想怎么会出现这个错误呢,
解决: Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1). Searched in the following locations: ...
Cannot resolve org.jeecgframework.boot:codegenerate:1.0.7; missing artifact org.jeecgframework * jar; jeecg maven 经常访问不了,jeecg boot 中的 jar 不能下载,可以下载这个放到本地 maven 库即可; ...
Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.hibernate.connection.C3P0ConnectionProvider] at org.hibernate.engine.jdbc.connections.internal....
Maven更新问题 今天Maven在更新的时候发现一直更新不成功,总结下解决方法。 在apache-maven-3.5.2/conf/setting.xml中加入以下配置即可解决 alimaven aliyun maven ... central junit junit Address/ ...
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method qt....
在使用Maven构建Java项目时,可能会遇到这样一个错误:“Failed to execute goal on project …: Could not resolve dependencies for project …”。这个错误通常表明Maven在构建过程中遇到了依赖解析问题,无法...
首先,错误的具体信息是`Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ‘:classpath’`,...
Maven坐标:org.apache.httpcomponents:httpclient:4.5.13; 标签:apache、httpcomponents、httpclient、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
在一次代码拉取中,出现了以下问题:Could not download groovy-all.jar (org.codehaus.groovy:groovy-all:2.4.15) 详细的报错信息如下: // 报错信息如下 Could not resolve all files for configuration ':jcore-...
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.connection.C3P0ConnectionProvider] as strategy [org.hibernate.engine.jdbc.... ...
Maven坐标:org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016; 标签:eclipse、jetty、orbit、javax、servlet、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html...
要在主工程的gradle中添加版本信息或者自己在资源包中添加版本号,依赖此资源就可以实现FlexboxLayout与Recycleview的后续操作,我的主工程版本代码: ext { minSdkVersion = 9 targetSdkVersion = 25 ...
org.vaadin.addons.dcharts-widget-0.10.0-dcharts-widget-0.10.0.jar
jar包,官方版本,自测可用
Jar包:sqljdbc4-4.0.jar