我正在使用 jhipster 標(biāo)準(zhǔn)和 jpa 規(guī)范來(lái)實(shí)現(xiàn)一個(gè)端點(diǎn)進(jìn)行研究。好吧,它正在工作,但請(qǐng)繼續(xù)向我發(fā)送副本。有這個(gè)模型的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<>();以及公司與財(cái)產(chǎn)之間的關(guān)系@OneToMany(mappedBy = "company", cascade = CascadeType.ALL, orphanRemoval = true)@LazyCollection(LazyCollectionOption.FALSE)private List<CompanyPrestation> prestations = new ArrayList<>();
1 回答
蕪湖不蕪
TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超7個(gè)贊
在你的toPredicate方法里面,你能做到嗎?
@Override
public Predicate toPredicate(Root<Company> roots, CriteriaQuery<?> query, CriteriaBuilder builder) {
....
query.distinct(true);
return ...;
}
來(lái)自 > CriteriaQuery#distinct
盡管您嘗試做的事情可能不可能,但據(jù)說(shuō)這是JPA的限制
您可以嘗試做的是在獲取后刪除代碼中的重復(fù)項(xiàng),或者嘗試覆蓋equals& hashCode方法以嘗試破解不同的定義?
添加回答
舉報(bào)
0/150
提交
取消
