企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
**示例1:** ```sql select p1.* from tb_person p1 left join tb_bank_card b1 on p1.id=b1.persion_id where p1.username='zhangsan' and b1.card_num='1234-5678' ``` ```java Specification<Person> spec = (root, query, cBuilder) -> { List<Predicate> predicates = new ArrayList<>(16); //bankCardList:对应 Person#bankCardList 变量名 Join<Person, BankCard> leftJoin = root.join("bankCardList", JoinType.LEFT); //root.get 是设置主表查询条件 //leftJoin.get 是设置从表查询条件 predicates.add(cBuilder.equal(root.get("username"), "zhangsan")); predicates.add(cBuilder.equal(leftJoin.get("cardNumber"), "1234-5678")); query.where(predicates.toArray(new Predicate[predicates.size()])); return query.getRestriction(); }; Person person = personRepository.findOne(spec).orElse(null); ```