如何解读Specification.where
如何解读Spring boot jpa中Specification的如下方法:
static
return spec == null ? (root, query, builder) -> null : spec;
}
有文字解释,这里只摘录代码部分。
Bard
Specification
@Override
public Predicate toPredicate(Root
return builder.equal(root.get("name"), "John Doe");
}
};
Specification
@Override
public Predicate toPredicate(Root
return builder.greaterThan(root.get("age"), 21);
}
};
Specification
List
这句Specification
ChatGPT
Specification
Specification
Specification
List
books.forEach(b -> log.debug("{}{-}", b.getIsbn(), b.getPrice()));
文心一言
List
people.add(new Person("Alice", 25));
people.add(new Person("Bob", 20));
people.add(new Person("Charlie", 30));
List
Specification
filteredPeople.addAll(people.stream().filter(specification).collect(Collectors.toList()));
也是有明显错误。
Bard、文心一言水平差不多,ChatGPT独领风骚。
精彩文章
发表评论