hibernate OneToMany criteria returns duplicates

前端 未结 1 643
梦谈多话
梦谈多话 2021-01-05 08:24

I have an association mapped by the following:

@Entity
public class Parent
{
...
    @Id
    @Column(name = \"parent_id\")
    private Long id;

    @OneToMa         


        
1条回答
  •  被撕碎了的回忆
    2021-01-05 09:10

    You need to add a distinct, e.g.

    criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    

    should work in your case

    0 讨论(0)
提交回复
热议问题