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
Mysql 当子查询使用查询字段进行比较时,如何构建条件休眠子查询_Mysql_Hibernate_Hibernate Criteria_Criteria Api_Detachedcriteria - Fatal编程技术网

Mysql 当子查询使用查询字段进行比较时,如何构建条件休眠子查询

Mysql 当子查询使用查询字段进行比较时,如何构建条件休眠子查询,mysql,hibernate,hibernate-criteria,criteria-api,detachedcriteria,Mysql,Hibernate,Hibernate Criteria,Criteria Api,Detachedcriteria,我正在尝试使用子查询构建一个条件查询。我读了很多关于创建子查询的detachedcriteria的书,但是找不到关于选择另一个select(而是where子句上的子查询等)的任何内容 每当用户与应用程序交互时,应用程序都会向交互表中插入一行数据 我想提出的问题是: 统计特定月份内按天分组的所有交互,并统计同一特定月份内按天分组的所有特定交互用户 我可以在SQL中构建的查询是 select DAY(intsys.dateReg) all_days , count(intsys.id) all_i

我正在尝试使用子查询构建一个条件查询。我读了很多关于创建子查询的detachedcriteria的书,但是找不到关于选择另一个select(而是where子句上的子查询等)的任何内容

每当用户与应用程序交互时,应用程序都会向交互表中插入一行数据

我想提出的问题是:

统计特定月份内按天分组的所有交互,并统计同一特定月份内按天分组的所有特定交互用户

我可以在SQL中构建的查询是

select DAY(intsys.dateReg) all_days ,
 count(intsys.id) all_interactions, 
 (select count(us.id) from Interaction us where us.user_id = 2 and MONTH(us.dateReg) = 7 and DAY(us.dateReg) = DAY(intsys.dateReg)) user_interactions 
from Interaction intsys
where MONTH(intsys.dateReg) = 7 group by DAY(intsys.dateReg);
结果与预期完全一致:

有人能帮我用CriteriaAPI重现这个查询吗