Spring 带有表达式的JPA规范

Spring 带有表达式的JPA规范,spring,jpa,Spring,Jpa,我有一个使用这种语法构建的JPA规范 newSpec = (root, query, cb) -> { return cb.equal(root.get("livelloApprovazione"), root.join( "utentiInteressati").get("livello")); }; 正确映射到本机SQL方面的: select .... from documento document

我有一个使用这种语法构建的JPA规范

newSpec = (root, query, cb) -> {        
    return cb.equal(root.get("livelloApprovazione"), root.join( "utentiInteressati").get("livello"));
};
正确映射到本机SQL方面的:

select .... 
from documento documento0_ 
inner join documento_utenti utentiinte1_ 
    on documento0_.id_documento=utentiinte1_.id_documento 
where documento0_.livello_approvazione=utentiinte1_.livello 
我需要的是在条件的左侧添加一个+1表达式

select .... 
    ....
where documento0_.livello_approvazione + 1 = utentiinte1_.livello 
在条件的一侧使用附加表达式+1

是否有可能实现像JPA规范谓词这样的where条件?如果是,怎么做?

试试这个

    newSpec = (root, query, cb) -> 
            cb.equal(
                    cb.sum(root.get("livelloApprovazione"), 1), 
                    root.join( "utentiInteressati").get("livello")
            );

感谢您的回答,我想这可能对您的探索很有用。我在检查Intellij中cb.equal的签名。它将2个表达式作为参数。然后我检查了
Expression
接口的实现,其中一个是
binaryarthmeticsexpression