Hibernate 一对多自动筛选配置
用注解配置一对多端 如下
@OneToMany(mappedBy="book",fetch=FetchType.LAZY)
private List<BorrowRecord> borrowRecords;
多对一端
@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, optional = true)
@JoinColumn(name = "bookid",nullable=false)
private Book book;
现希望hibernate 帮忙完成在得到borrowRecords时自动筛选其BorrowRecord对象enable为true的
------解决方案--------------------
@OneToMany(mappedBy="book",fetch=FetchType.LAZY)
@Where(clause="enable=true")//加入试试
private List<BorrowRecord> borrowRecords;