[英]QueryDsl how to use exist() to return boolean
I want to upgrade queryDsl from verision 3 to version 4. But i've an issue with exist() In QueryDsl 3 exist return a Boolean but in QUeryDSL 4 it return a BooleanOperation.我想将 queryDsl 从版本 3 升级到版本 4。但我有一个问题,exist() 在 QueryDsl 3 中存在返回一个布尔值,但在 QUeryDSL 4 中它返回一个 BooleanOperation。 In my case i really want the boolean but i don't know how to retrieve it.就我而言,我真的想要布尔值,但我不知道如何检索它。
The best solution i've found is to do我发现的最好的解决方案是做
.fetchCount() >0
But I want to know if another (better) solution exist.但我想知道是否存在另一个(更好的)解决方案。
Another option would be something like:另一种选择是这样的:
queryFactory.select(queryField).from(qTable)
.where(queryField.eq(value))
.groupBy(queryField)
.having(qTable.uuid.count().gt(0))
.fetchOne() != null;
This passes the greater than responsibility over to the query.这将大于责任传递给查询。 However it is possibly less readible so will depend on the requirements which is better.但是,它的可读性可能较差,因此将取决于更好的要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.