帮帮我吧~Unable to locate appropriate constructor on class

问题描述

报错:org.hibernate.hql.ast.QuerySyntaxException:Unabletolocateappropriateconstructoronclass代码是Queryquery=session.createQuery("selectBuyPlanning(t.id,t.pcode,t.pdatd,t.entryusername,t.bossdatd,t.recordlock,t.recordstatus,t.recordshow,t.departmentcode,t.enterprisecode)fromBuyPlanningast,ErpSystemCheckingasvwheret.pcode=v.pcodeandv.numid="+String.valueOf(numid));其中BuyPlanning和ErpSystemChecking都是通过myeclipse直接对数据表做的“HibernateReverseEngineering”获得的publicclassBuyPlanningextendsAbstractBuyPlanningimplementsjava.io.Serializable{//Constructors/**defaultconstructor*/publicBuyPlanning(){}/**minimalconstructor*/publicBuyPlanning(Integerid){super(id);}/**fullconstructor*/publicBuyPlanning(Integerid,Stringpcode,Timestamppdatd,Stringentryusername,Timestampbossdatd,Stringrecordlock,Stringrecordstatus,Stringrecordshow,Stringdepartmentcode,Stringenterprisecode){super(id,pcode,pdatd,entryusername,bossdatd,recordlock,recordstatus,recordshow,departmentcode,enterprisecode);}}publicabstractclassAbstractBuyPlanningimplementsjava.io.Serializable{//FieldsprivateIntegerid;privateStringpcode;privateTimestamppdatd;privateStringentryusername;privateTimestampbossdatd;privateStringrecordlock;privateStringrecordstatus;privateStringrecordshow;privateStringdepartmentcode;privateStringenterprisecode;//Constructors/**defaultconstructor*/publicAbstractBuyPlanning(){}/**minimalconstructor*/publicAbstractBuyPlanning(Integerid){this.id=id;}/**fullconstructor*/publicAbstractBuyPlanning(Integerid,Stringpcode,Timestamppdatd,Stringentryusername,Timestampbossdatd,Stringrecordlock,Stringrecordstatus,Stringrecordshow,Stringdepartmentcode,Stringenterprisecode){this.id=id;this.pcode=pcode;this.pdatd=pdatd;this.entryusername=entryusername;this.bossdatd=bossdatd;this.recordlock=recordlock;this.recordstatus=recordstatus;this.recordshow=recordshow;this.departmentcode=departmentcode;this.enterprisecode=enterprisecode;}//PropertyaccessorspublicIntegergetId(){returnthis.id;}publicvoidsetId(Integerid){this.id=id;}publicStringgetPcode(){returnthis.pcode;}publicvoidsetPcode(Stringpcode){this.pcode=pcode;}publicTimestampgetPdatd(){returnthis.pdatd;}publicvoidsetPdatd(Timestamppdatd){this.pdatd=pdatd;}publicStringgetEntryusername(){returnthis.entryusername;}publicvoidsetEntryusername(Stringentryusername){this.entryusername=entryusername;}publicTimestampgetBossdatd(){returnthis.bossdatd;}publicvoidsetBossdatd(Timestampbossdatd){this.bossdatd=bossdatd;}publicStringgetRecordlock(){returnthis.recordlock;}publicvoidsetRecordlock(Stringrecordlock){this.recordlock=recordlock;}publicStringgetRecordstatus(){returnthis.recordstatus;}publicvoidsetRecordstatus(Stringrecordstatus){this.recordstatus=recordstatus;}publicStringgetRecordshow(){returnthis.recordshow;}publicvoidsetRecordshow(Stringrecordshow){this.recordshow=recordshow;}publicStringgetDepartmentcode(){returnthis.departmentcode;}publicvoidsetDepartmentcode(Stringdepartmentcode){this.departmentcode=departmentcode;}publicStringgetEnterprisecode(){returnthis.enterprisecode;}publicvoidsetEnterprisecode(Stringenterprisecode){this.enterprisecode=enterprisecode;}}

解决方案

解决方案二:
org.hibernate.hql.ast.QuerySyntaxException:Unabletolocateappropriateconstructoronclass要重点检查全参数构造器的参数类型是否正确了,这是最常发生的问题。
解决方案三:
org.hibernate.hql.ast.QuerySyntaxException:Unabletolocateappropriateconstructoronclass找不到合适的构造方法。selectBuyPlanning(t.id,t.pcode,t.pdatd,t.entryusername,t.bossdatd,t.recordlock,t.recordstatus,t.recordshow,t.departmentcode,t.enterprisecode)查看一下构成BuyPlanning这个对象的构造方法的参数个数、参数类型与上面这个hql语句中查询的字段个数、字段类型是否都匹配。扫了一眼,好像参数个数是一样的,看是不是字段类型与参数类型不一致导致的。
解决方案四:
你的HQL没有写对啊Queryquery=session.createQuery("selectBuyPlanning(t.id,t.pcode,t.pdatd,t.entryusername,t.bossdatd,t.recordlock,t.recordstatus,t.recordshow,t.departmentcode,t.enterprisecode)fromBuyPlanningast,ErpSystemCheckingasvwheret.pcode=v.pcodeandv.numid="+String.valueOf(numid));改为Queryquery=session.createQuery("selectnewBuyPlanning(t.id,t.pcode,t.pdatd,t.entryusername,t.bossdatd,t.recordlock,t.recordstatus,t.recordshow,t.departmentcode,t.enterprisecode)fromBuyPlanningast,ErpSystemCheckingasvwheret.pcode=v.pcodeandv.numid="+String.valueOf(numid));少了一个“new”
解决方案五:
你的fullconstructor和minimalconstructor检查这两个构造函数的数据类型和你配置文件里定义的是否匹配。下面的链接供你参考。
解决方案六:
我发帖发错了,是有那个new的引用3楼的回复:

你的HQL没有写对啊Queryquery=session.createQuery("selectBuyPlanning(t.id,t.pcode,t.pdatd,t.entryusername,t.bossdatd,t.recordlock,t.recordstatus,t.recordshow,t.departmentcode,t.enterprisecode)fromBuyPla……

解决方案七:
数据库的数据是[id][int]IDENTITY(1,1)NOTNULL,[pcode][nvarchar](50)COLLATEChinese_PRC_CI_ASNULL,[pdatd][datetime]NULL,[entryusername][nvarchar](20)COLLATEChinese_PRC_CI_ASNULL,[bossdatd][datetime]NULL,[recordlock][nvarchar](1)COLLATEChinese_PRC_CI_ASNULL,[recordstatus][nvarchar](1)COLLATEChinese_PRC_CI_ASNULL,[recordshow][nvarchar](1)COLLATEChinese_PRC_CI_ASNULL,[departmentcode][nvarchar](50)COLLATEChinese_PRC_CI_ASNULL,[enterprisecode][nvarchar](50)COLLATEChinese_PRC_CI_ASNULL析构函数的数据是privateIntegerid;privateStringpcode;privateTimestamppdatd;privateStringentryusername;privateTimestampbossdatd;privateStringrecordlock;privateStringrecordstatus;privateStringrecordshow;privateStringdepartmentcode;privateStringenterprisecode;有错吗?引用2楼的回复:

org.hibernate.hql.ast.QuerySyntaxException:Unabletolocateappropriateconstructoronclass找不到合适的构造方法。selectBuyPlanning(t.id,t.pcode,t.pdatd,t.entryusername,t.bossdatd,t.recordlock,t.records……

解决方案八:
publicclassBuyPlanningextendsAbstractBuyPlanningimplementsjava.io.Serializable{//Constructors/**defaultconstructor*/publicBuyPlanning(){}/**minimalconstructor*/publicBuyPlanning(Integerid){super(id);}/**fullconstructor*/publicBuyPlanning(Integerid,Stringpcode,Timestamppdatd,Stringentryusername,Timestampbossdatd,Stringrecordlock,Stringrecordstatus,Stringrecordshow,Stringdepartmentcode,Stringenterprisecode){super(id,pcode,pdatd,entryusername,bossdatd,recordlock,recordstatus,recordshow,departmentcode,enterprisecode);}}和这个publicabstractclassAbstractBuyPlanningimplementsjava.io.Serializable{//FieldsprivateIntegerid;privateStringpcode;privateTimestamppdatd;privateStringentryusername;privateTimestampbossdatd;privateStringrecordlock;privateStringrecordstatus;privateStringrecordshow;privateStringdepartmentcode;privateStringenterprisecode;//Constructors/**defaultconstructor*/publicAbstractBuyPlanning(){}/**minimalconstructor*/publicAbstractBuyPlanning(Integerid){this.id=id;}/**fullconstructor*/publicAbstractBuyPlanning(Integerid,Stringpcode,Timestamppdatd,Stringentryusername,Timestampbossdatd,Stringrecordlock,Stringrecordstatus,Stringrecordshow,Stringdepartmentcode,Stringenterprisecode){this.id=id;this.pcode=pcode;this.pdatd=pdatd;this.entryusername=entryusername;this.bossdatd=bossdatd;this.recordlock=recordlock;this.recordstatus=recordstatus;this.recordshow=recordshow;this.departmentcode=departmentcode;this.enterprisecode=enterprisecode;}没有问题啊引用4楼的回复:

你的fullconstructor和minimalconstructor检查这两个构造函数的数据类型和你配置文件里定义的是否匹配。下面的链接供你参考。http://blog.csdn.net/yangsp1/article/details/4375910

解决方案九:
怎么搞,我也是这个问题
解决方案十:
我觉得你*.hbm.xml文件跟你的pojo类*.java的数据类型没有对应

时间: 2024-10-25 08:54:07

帮帮我吧~Unable to locate appropriate constructor on class的相关文章

ERROR:internal error Unable to locate libvirtd daem错误

在编译配置libvirt12.2时如果prefix不是usr目录,在使用libvirt创建VM则会出现 ERROR:internal error Unable to locate libvirtd daemon in $PATH 即便libvirtd所在目录已经加入了PATH.本人认为这是libvirt一个bug. 解决方法是:把你的libvirtd链接到/usr下 #pwd /usr #ln -s /usr/local/libvirt/sbin/libvirtd libvirtd 上面问题解决

Unable to locate Spring NamespaceHandler for XML schema namespace

目前做的项目,其中一个模块是由我负责,采用hibernate和spring,没有使用struts.是一个socket 服务器,运行主类的main方法即启动程序. 使用IDE:eclipse 构建工具:maven   在eclipse中运行没问题,但是使用maven的maven-assembly-plugin 插件打包成为可执行的jar后,在命令行中运行: Java -jar xxx.jar 报错:Unable to locate Spring NamespaceHandler for XML s

ubuntu12.10在apt-get时提示 E: Unable to locate package libncurses5-dev

问题描述 ubuntu12.10在apt-get时提示 E: Unable to locate package libncurses5-dev jaden@ubuntu:/etc/apt$ sudo apt-get install libncurses5-dev Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package l

Unable to locate Spring for XML schema [http:/org.springfamework/schema/context]

问题描述 问题是:Configurationproblem:UnabletolocateSpringNamespaceHandlerforXMLschemanamespace[http://www.springframework.org/schema/context]Offendingresource:ServletContextresource[/WEB-INF/context/applicationContext.xml]这是spring的application.xml:<?xmlversi

Unable to locate the xml-definition for FieldName with FieldId

问题描述 最近检查SharepointLog,有极大量以下的logs,大概每分钟2-3个:Unabletolocatethexml-definitionforFieldNamewithFieldId'xxxx-xxxx-xxxx-xxxx',exception:Microsoft.SharePoint.SPException:Catastrophicfailure(ExceptionfromHRESULT:0x8000FFFF(E_UNEXPECTED))--->System.Runtime.I

Java的Hibernate框架中用于操作数据库的HQL语句讲解_java

 上次我们一起学习了用Criteria进行相关的操作,但由于Criteria并不是Hibernate官方推荐的查询方式,我们也并不多用.现在我们来看一下官方推荐的HQL,一起学习一下它的强大.  说是HQL,也就是Hibernate查询语句,和SQL有什么区别呢?一个字母的区别,哈哈.  当然不是这样,HQL和SQL的区别在于思想的不同,HQL是用面向对象的方向进行查询,而SQL则是对数据库二维表进行查询,这里包含的是思想的不同.HQL实际上也是SQL,它由Hibernate帮我们在内部进行转换

Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建(转)

这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 如果还没有搭建好环境(主要是Maven+MySQL的配置)的猿友可以参考博主以前的一篇文章: http://blog.csdn.net/u013142781/article/details/50300233 接下来马上进入项目搭建过程: 1.创建表,并插入数据: CREATE DATABASE `ssi` /*!4010

GWT 项目开发 1.6.4 本地开发 appengine-tools-api 突破限制

经过研究发现.google 的限制jar 是   appengine-tools-api    修改类:   com.google.appengine.tools.development.DevAppServerFactory   就可以再本地环境适应 hibernate 连接数据库.创建线程,创建文件等操作.(当然你改的是本地环境.google服务器上的是没有办法了.)   这样做主要是为了开发 gwt 应用的.   修改类如下:     /*jadclipse*/// Decompiled

python实现封装得到virustotal扫描结果_python

本文实例讲述了python实现封装得到virustotal扫描结果的方法.分享给大家供大家参考.具体方法如下: import simplejson import urllib import urllib2 import os, sys import logging try: import sqlite3 except ImportError: sys.stderr.write("ERROR: Unable to locate Python SQLite3 module. " \ &qu