0

我有一个现有框架提供的 JPA 规范。只有在 Specification 中已经有特定的 Predicate 时,我才想向 Specification 添加一个值。

示例伪代码:

public getBook(Specification specification) {
    if ( **check here if specification already has a predicate for X=Y** ) {
       spcecification.or(...)
    }
}

或者也许在这里


static Specification<Book> titleContains(String title) {
    return (book, cq, cb) -> {
        if ( **check here if specification already has a predicate for X=Y** ) {
          cb.like(book.get("title"), "%" + title + "%"
        }
    });
}

如何检查规范的现有值?

4

0 回答 0