日期:2014-05-20  浏览次数:20922 次

hql 的问题 极度让我头疼 快来帮忙 得分多多
select sum(loan.l_money) from loan,mainInfo where loan.l_ID_number=mainInfo.m_ID_number and mainInfo.m_addr like '1155______' group by loan.l_ID_number
这个东西老错
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.AggregateNode
\-[AGGREGATE] AggregateNode: 'sum' 

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="entity.loan.loan" table="loan">
<id name="l_id" column="l_id" type="int">
<generator class="native"/>
</id>
<property name="l_ID_number" column="l_ID_number" length="18" type="java.lang.String"/>
<property name="l_organ_code" column="l_organ_code" length="12" type="java.lang.String"/>
<property name="l_business" column="l_business" length="10" type="java.lang.String"/>
<property name="l_open_date" column="l_open_date" type="date"/>
<property name="l_mature_date" column="l_mature_date" type="date"/>
<property name="l_money" column="l_money" type="java.math.BigDecimal"/>
<property name="l_assurance" column="l_assurance" length="1" type="java.lang.String"/>
<property name="l_balance" column="l_balance" type="java.math.BigDecimal"/>
<property name="l_overdue_money" column="l_overdue_money" type="java.math.BigDecimal"/>
<property name="l_overdue_day" column="l_overdue_day" type="int"/>
<property name="l_five_categories" column="l_five_categories" length="2" type="java.lang.String"/>
<property name="l_status" column="l_status" length="2" type="java.lang.String"/>

</class>
</hibernate-mapping>

------解决方案--------------------
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.AggregateNode

非法的状态!~!你好好看看你什么地方用错了东西
------解决方案--------------------
接楼上!~!
你用断点追踪一下!~!应该这个问题会很快解决的
------解决方案--------------------
select loan.l_ID_number ,sum(loan.l_money) from loan,mainInfo where loan.l_ID_number=mainInfo.m_ID_number and mainInfo.m_addr like '1155______' group by loan.l_ID_number 

------解决方案--------------------
分组的字段一定要在select 列表里面,楼上的对了,如果还是不行,那就是hql不支持这种写法,那用 hibernate 的native sql就可以了,只要保证你这句sql语法没问题。
------解决方案--------------------
同意3楼的说法!!!!
同意3楼的说法!!!!
同意3楼的说法!!!!
同意3楼的说法!!!!