我有一个存储库
public interface GroupRepository extends JpaRepository<Group, Integer> {
}
该组确实有一个项目清单
private List<Item> items;
每个Item都有一个position属性
private int position;
如何通过知道其中一个列表中存在的项目的位置来检索组 ?
项目.java
public class Item extends PersistedBean{
private int position;
private Group group;
@Column(name = "Position")
public int getPosition() {
return position;
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "GroupId", referencedColumnName = "Id")
public Group getGroup() {
return group;
}
}
组.java
public class Group extends PersistedBean {
private int position;
private List<Item> items;
@Column(name = "Position")
public int getPosition() {
return position;
}
@OneToMany(cascade = CascadeType.ALL, mappedBy = "group", orphanRemoval = false)
public List<Item> getItems() {
return items;
}
}
慕哥9229398
相关分类