我正在使用 jhipster 标准和 jpa 规范来实现一个端点进行研究。好吧,它正在工作,但请继续向我发送副本。有这个模型的prestationspublic class Prestation extends AbstractAuditingEntity implements Serializable {private static final long serialVersionUID = 1L;@Id@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")@SequenceGenerator(name = "sequenceGenerator")private Long id;@NotNull@Column(name = "jhi_label", nullable = false)private String label;@Column(name = "description")private String description;@Column(name = "unit")private String unit;@NotNull@Column(name = "activated", nullable = false)private boolean activated;@ManyToOne(optional = false)@NotNull@JsonIgnoreProperties("prestations")private SubCategory subCategory;@OneToMany(mappedBy = "prestation", cascade = CascadeType.ALL, orphanRemoval = true)private List<CompanyPrestation> companies = new ArrayList<>();以及公司与财产之间的关系@OneToMany(mappedBy = "company", cascade = CascadeType.ALL, orphanRemoval = true)@LazyCollection(LazyCollectionOption.FALSE)private List<CompanyPrestation> prestations = new ArrayList<>();
1 回答
芜湖不芜
TA贡献1796条经验 获得超7个赞
在你的toPredicate方法里面,你能做到吗?
@Override
public Predicate toPredicate(Root<Company> roots, CriteriaQuery<?> query, CriteriaBuilder builder) {
....
query.distinct(true);
return ...;
}
来自 > CriteriaQuery#distinct
尽管您尝试做的事情可能不可能,但据说这是JPA的限制
您可以尝试做的是在获取后删除代码中的重复项,或者尝试覆盖equals& hashCode方法以尝试破解不同的定义?
添加回答
举报
0/150
提交
取消