No data type for node: org.hibernate.hql.ast.tree.MethodNode

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了No data type for node: org.hibernate.hql.ast.tree.MethodNode相关的知识,希望对你有一定的参考价值。

我用的是struts1.2 hibernate3.0 spring 1.2 tomcat5.5 Eclipse3.2
dao:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String now=sdf.format(new Date());
String hql="select p.id,DATEDIFF(d,'"+now+"','"+endtime+"') as day from "+poname+" p where DATEDIFF(d,'"+now+"','"+endtime+"') between 0 and 30 "; //计算endtime到now的天数

action:
int day=0;
List daylist=zhwcarService.getDays(info.getEndTime(), "WsyVehicleinsuranceInfo");
for (Iterator iter = daylist.iterator(); iter.hasNext();)
Integer days[]=(Integer[]) iter.next();
day=days[1]; System.out.println("day[0]= "+days[0]+" day[1]= "+days[1]);

然后控制台上就出现了:
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'DATEDIFF' originalText=DATEDIFF
\-[EXPR_LIST] SqlNode: 'exprList'
+-[IDENT] IdentNode: 'd' originalText=d
+-[QUOTED_STRING] LiteralNode: ''2010-03-29''
\-[QUOTED_STRING] LiteralNode: ''2010-04-10''

at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:140)
at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:702)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:531)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:645)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1583)
at org.springframework.orm.hibernate3.HibernateTemplate$31.doInHibernate(HibernateTemplate.java:846)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:844)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836)
at com.oa.zhw.managercar.daoimpl.ZHWCarDaoImpl.getDays(ZHWCarDaoImpl.java:152)
at com.oa.zhw.managercar.serviceimpl.ZHWCarServiceImpl.getDays(ZHWCarServiceImpl.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

参考技术A String hql="select p.id,DATEDIFF(d,'"+now+"','"+endtime+"') as day from "+poname+" p where DATEDIFF(d,'"+now+"','"+endtime+"') between 0 and 30 "; //计算endtime到now的天数

这里改成以下内容再试试
String hql="select p.id,to_char(DATEDIFF(d,'"+now+"','"+endtime+"')) as day from "+poname+" p where DATEDIFF(d,'"+now+"','"+endtime+"') between 0 and 30 "; //计算endtime到now的天数

No converter found for return value of type: class

错误产生环境

SpringBoot项目响应数据时产生

错误描述

converter.HttpMessageNotWritableException: No converter found for return value of type: 

错误原因

调用的实体类没有加上getter和Setter方法

解决办法

给提供getter和Setter方法 或者使用lombox插件的@Data注解

以上是关于No data type for node: org.hibernate.hql.ast.tree.MethodNode的主要内容,如果未能解决你的问题,请参考以下文章

oracle impdp 出错 ORA-31655: no data or metadata objects selected for job ORA-39154:

Spring Boot 启动出现"no property find found for type"

mongodb 分页报错 too much data for sort() with no index. add an index or specify a smaller limit

No such file or directory

No converter found for return value of type: class

No converter found for return value of type: class