休眠条件多个子查询

时间:2019-01-21 17:51:15

标签: java hibernate spring-boot criteria

在使用Hibernate创建子查询时遇到问题。不幸的是Subqueries类几乎完全没有文档,因此我完全不知道如何将以下SQL转换为Hibernate Criteria:

SELECT *,
(SELECT COUNT(*) FROM tweet.like    WHERE tweet.like.postid = tweet.post.postid)  AS    like_count,
(EXISTS(SELECT 1 FROM tweet.like    WHERE tweet.like.postid = tweet.post.postid   AND   tweet.like.userid = 29 )) AS islike
FROM tweet.post
INNER JOIN  tweet.users  ON tweet.users.userid = tweet.post.userid;

0 个答案:

没有答案