Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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 hql查询与返回空值的sum()函数一起使用_Java_Hibernate_Hql - Fatal编程技术网

Java Hibernate hql查询与返回空值的sum()函数一起使用

Java Hibernate hql查询与返回空值的sum()函数一起使用,java,hibernate,hql,Java,Hibernate,Hql,嗨,我试着执行这个查询,它在mysql数据库中正常运行。通过使用hibernate返回空值,您能解释一下karthik提前感谢我吗 string = "SELECT sum(feed1Consumed),sum(feed2Consumed)" + "FROM com.ebiodata.upstream.pojo.UpstreamMammalianFermentationTempUpdate" + " where upstreamHeader.id=\'" +

嗨,我试着执行这个查询,它在mysql数据库中正常运行。通过使用hibernate返回空值,您能解释一下karthik提前感谢我吗

string = "SELECT sum(feed1Consumed),sum(feed2Consumed)"
         + "FROM com.ebiodata.upstream.pojo.UpstreamMammalianFermentationTempUpdate"
         + " where upstreamHeader.id=\'" + serializableId + "\'";
如果所有求和行的求和值均为null,或者未找到任何行,则sum()返回null

hibernate.cfg.xml
中,可以使用
true
查看由hibernate生成的SQL语句

我不明白为什么要将id作为字符串进行比较
serializableId
可能是一个数字。您可以与进行数字比较

" where upstreamHeader.id=" + serializableId;