Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Hibernate中按查询编写此组?_Java_Hibernate - Fatal编程技术网

Java 如何在Hibernate中按查询编写此组?

Java 如何在Hibernate中按查询编写此组?,java,hibernate,Java,Hibernate,这是对sql的查询 SELECT type ,SUM(amount) FROM CustomerPayment GROUP BY type 如何在hibernate中编写此代码?在hql中也是如此: 按c.type从CustomerPayment c组中选择c.type,sum(c.amount)上面的代码给出了org.hibernate.query异常:在预期中:c[按c.type从CustomerPayment c组中选择c.type,sum(c.amount)]org.hibernate

这是对sql的查询

SELECT type ,SUM(amount) FROM CustomerPayment GROUP BY type
如何在hibernate中编写此代码?

在hql中也是如此:


按c.type从CustomerPayment c组中选择c.type,sum(c.amount)

上面的代码给出了org.hibernate.query异常:在预期中:c[按c.type从CustomerPayment c组中选择c.type,sum(c.amount)]org.hibernate.hql.classic.FromParser.token(FromParser.java:106)错误发布
CustomerPayment
实体的代码。我假设您的amount和type列映射到了相应的字段。是的,我的表中有它们我相信您的实体在Hibernate中没有正确映射,您能否从CustomerPayment执行
查询?