gpt4 book ai didi

java.lang.IllegalArgumentException : org. hibernate.QueryException : No data type for node: org. hibernate.hql.internal.ast.tree.MethodNode

转载 作者:太空宇宙 更新时间:2023-11-04 10:23:45 51 4
gpt4 key购买 nike

我正在尝试跟踪此异常,但不理解它,请查看我的异常并请让我知道我哪里出错了

java.lang.IllegalArgumentException: org.hibernate.QueryException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode 
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'STR_TO_DATE' {originalText=STR_TO_DATE}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[DOT] DotNode: 'feetermdat4_.date' {propertyName=date,dereferenceType=PRIMITIVE,getPropertyPath=date,path=ff.date,tableAlias=feetermdat4_,className=com.rasvek.cg.entity.FeeTermDates,classAlias=ff}
| +-[ALIAS_REF] IdentNode: 'feetermdat4_.tdm_id' {alias=ff, className=com.rasvek.cg.entity.FeeTermDates, tableAlias=feetermdat4_}
| \-[IDENT] IdentNode: 'date' {originalText=date}
\-[QUOTED_STRING] LiteralNode: ''%d/%m/%Y''
[select STR_TO_DATE(ftd.date, '%d/%m/%Y') as installmentDate,sum(fi.amount) as installmentAmount from com.rasvek.cg.entity.AssocFeeStudent afs,com.rasvek.cg.entity.FeeTermDates ftd ,com.rasvek.cg.entity.FeeClassMapping fcm ,com.rasvek.cg.entity.FeeIntallments fi where fcm.feeCategory.feeCatId= :fcmFeeCatId and fi.feeClassMappingId=fcm.feeClassMappingId and afs.feeCategory.feeCatId= :afsFeeCatId and afs.studentDetails.studentAdmissionId= :studentAdmissionId and fi.termDateId=ftd.tdmId and STR_TO_DATE(fi.termDate, '%d/%m/%Y') <= ( select STR_TO_DATE(ff.date, '%d/%m/%Y') from com.rasvek.cg.entity.FeeTermDates ff where ff.tdmId= :ffTdmId) order by STR_TO_DATE(ftd.date, '%d/%m/%Y') asc]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:133)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:670)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:103)
at com.rasvek.cms.dao.MasterDaoImpl.getNewpaymentByStuIdNTermId(MasterDaoImpl.java:2531)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy548.getNewpaymentByStuIdNTermId(Unknown Source)
at com.rasvek.cms.service.MasterSeviceImpl.getNewpaymentByStuIdNTermId(MasterSeviceImpl.java:710)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy549.getNewpaymentByStuIdNTermId(Unknown Source)
at com.rasvek.cms.controller.MasterController.getNewpaymentByStuIdNTermId(MasterController.java:1907)
at com.rasvek.cms.controller.MasterController$$FastClassBySpringCGLIB$$c2eff8c2.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.rasvek.cms.controller.MasterController$$EnhancerBySpringCGLIB$$7421bf48.getNewpaymentByStuIdNTermId(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1100)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:687)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

我能够理解它,在我看来一切都是正确的,但我遇到了异常。

请查看我的查询:

select
STR_TO_DATE(ftd.date, '%d/%m/%Y') as installmentDate,
sum(fi.amount) as installmentAmount
from AssocFeeStudent afs, FeeTermDates ftd, FeeClassMapping fcm, FeeIntallments fi
where
fcm.feeCategory.feeCatId = :fcmFeeCatId and fi.feeClassMappingId = fcm.feeClassMappingId and afs.feeCategory.feeCatId = :afsFeeCatId and
afs.studentDetails.studentAdmissionId = :studentAdmissionId and fi.termDateId = ftd.tdmId and
STR_TO_DATE(fi.termDate, '%d/%m/%Y') <= (select STR_TO_DATE(ff.date, '%d/%m/%Y')
from FeeTermDates ff
where ff.tdmId = :ffTdmId)
order by STR_TO_DATE(ftd.date, '%d/%m/%Y') asc

在我看来,上述查询看起来是正确的,但有些地方出了问题。 但是相同的查询在我的 mysql WorkBench 中完美运行。

最佳答案

问题是您正在尝试使用 Hibernate 不支持的 STR_TO_DATE SQL 函数 query language .

您可能不想使用 HQL,而是使用 Hibernate 的 native query support ,它让您执行简单的 SQL

List<Object[]> result = entityManager.createNativeQuery("your query here")
.getResultList();

但是,您将失去 ORM 的优势,并在标量值列表的 for 中获得结果。

但是您根本不需要使用 STR_TO_DATE 转换日期,您可以直接使用 Date 实例作为 HQL 查询中的参数,即

session.createQuery("from FeeIntallments fi where where fi.termDateId >= :date")
.setParameter("date", new Date())
.list()

关于java.lang.IllegalArgumentException : org. hibernate.QueryException : No data type for node: org. hibernate.hql.internal.ast.tree.MethodNode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50792165/

51 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com