toPredicate()方法和和/或/不/在JPA标准API规范中的区别<>

时间:2018-06-15 10:10:24

标签: spring-data-jpa jpa-criteria

我现在正在探索用于创建动态查询和类型安全查询的JPA Criteria API。我正在探索如何使用规范。当我在探索时,我发现// SAVE DATA VSS.getService(VSS.ServiceIds.ExtensionData).then(function (dataService) { dataService.setValue("MY_VARIABLE", MY_VARIABLE_VALUE, { scopeType: User" }).then(function (value) { }); }); // GET DATA VSS.getService(VSS.ServiceIds.ExtensionData).then(function (dataService) { dataService.getValue("MY_VARIABLE", { scopeType: "User" }).then(function (value) { alert("Variable stored is equal to "+value); }); }); 方法用于为实体引用的查询创建where子句。还要探索And / Or / Not以及规范中的位置。

实际上如果toPredicate() mMethod创建where子句,那么为什么我们使用“Where”方法?比较toPredicate()方法时,其他方法的作用是什么?

1 个答案:

答案 0 :(得分:1)

如果您从头开始实施Specification,请实施toPredicate

如果您已有一个或多个Specification,则可以使用andornot将它们合并到新规范中。

例如,根据两个规范isVipplacedAnOrderLastMonth,您可以将它们组合在一起:

shouldReceiveNagMail = isVip.and(not(placedAnOrderLastMonth));

where方法只是人们可能想用来使代码更具可读性的语法糖。它只返回基本相同的Specification;