hibernate投影查询出错

y53ybaqx  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(262)

我正在尝试在hibernate中运行以下投影查询:

select new 
    com.allegiant.dmx.materials.dto.ToolMasterDto(t.recId,t.chgtype,  
  t.chgpage,t.chgdate,t.chguser,t.chgprog,t.partNumber,t.manufacturerName,
t.modelNumber,t.description,t.comments,t.cageCodeId,t.toolMasterStatusId)
 from com.allegiant.dmx.materials.domain.ToolMaster t  Where recId=1

我得到以下错误:

Caused by: org.hibernate.QueryException: could not instantiate class [com.allegiant.dmx.materials.dto.ToolMasterDto] from tuple
    at org.hibernate.transform.AliasToBeanConstructorResultTransformer.transformTuple(AliasToBeanConstructorResultTransformer.java:41) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.hql.internal.HolderInstantiator.instantiate(HolderInstantiator.java:85) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.loader.hql.QueryLoader.getResultList(QueryLoader.java:470) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.loader.Loader.list(Loader.java:2502) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1490) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    ... 133 common frames omitted
Caused by: java.lang.IllegalArgumentException: null
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_181]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_181]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_181]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_181]
    at org.hibernate.transform.AliasToBeanConstructorResultTransformer.transformTuple(AliasToBeanConstructorResultTransformer.java:37) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
    ... 143 common frames omitted

这是我的toolmasterdtoconstructor签名:

public ToolMasterDto(int rec_id,  String chgType, int chgPage, Date chgDate, String chgUser, String chgProg,
                     String partNumber, String manufacturerName, String modelNumber, String description, String comments,
                    Integer cageCodeId, Integer toolMasterStatus) {

谁能告诉我这个错误是从哪里来的吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题