spring data jpa Specification 多对一检索
来源:互联网 发布:mac上用什么输入法 编辑:程序博客网 时间:2024/05/18 12:29
一对多查询,以多的一方的ID查询一
@Entity
@Table(name = "refund_bill")
public class RefundBill extends IdEntity {
private List<Apply> applyList = Lists.newArrayList();
@OneToMany(mappedBy = "refundBill")
public List<Apply> getApplyList() {
return applyList;
}
public void setApplyList(List<Apply> applyList) {
this.applyList = applyList;
}
@Table(name = "apply")
public class Apply extends IdEntity {
private RefundBill refundBill;
@ManyToOne
@JoinColumn(name = "refund_bill_id", updatable = true)
public RefundBill getRefundBill() {
return refundBill;
this.refundBill = refundBill;
}
@Override
public Predicate toPredicate(Root<RefundBill> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Join<RefundBill, Apply> joins = root.join("applyList");
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(joins.<Long>get("id"), applyId));
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
}
}
@Entity
@Table(name = "refund_bill")
public class RefundBill extends IdEntity {
private List<Apply> applyList = Lists.newArrayList();
@OneToMany(mappedBy = "refundBill")
public List<Apply> getApplyList() {
return applyList;
}
public void setApplyList(List<Apply> applyList) {
this.applyList = applyList;
}
}
@Table(name = "apply")
public class Apply extends IdEntity {
private RefundBill refundBill;
@ManyToOne
@JoinColumn(name = "refund_bill_id", updatable = true)
public RefundBill getRefundBill() {
return refundBill;
}
this.refundBill = refundBill;
}
}
@Override
public Predicate toPredicate(Root<RefundBill> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Join<RefundBill, Apply> joins = root.join("applyList");
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(joins.<Long>get("id"), applyId));
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
}
}
0 0
- spring data jpa Specification 多对一检索
- Spring Data JPA Specification查询
- spring jpa data 查询多对一映射
- spring data jpa Specification的使用
- spring data jpa specification的封装
- spring-data-jpa Specification 拼接复杂查询
- spring data jpa(一)
- Spring data JPA使用Specification实现动态查询例子
- Spring Data JPA学习一
- Spring Data JPA 一Projections
- 3 Spring JPA Specification 查询
- spring-data-jpa 学习笔记一(转)
- Spring Data JPA教程:审计(一)
- Spring Data JPA 学习笔记(一)
- Spring Data Jpa开发学习笔记(一)
- JAVA操作数据库一(Spring data jpa)
- spring data jpa 使用(一)
- springboot中使用spring -data-jpa (一)
- android原生json包--对象转json
- win7下命令行
- iOS 消息推送原理及实现总结
- 传输线 模型 B 和电阻
- 将NTFS库编译进testdisk/photorec - CYGWIN平台
- spring data jpa Specification 多对一检索
- 让网页变灰色
- oracle chain
- 搜索引擎到人工智能的终极演进
- shell脚本里读取命令行参数
- Android中的系统广播集合
- TQFP 和LQFP 器件的焊接方法
- uva 10167 - Birthday Cake
- web maven jetty Unable to find a javac compiler