Is it valid for Hibernate list() to return duplicates?

后端 未结 4 700
-上瘾入骨i
-上瘾入骨i 2020-12-09 08:35

Is anyone aware of the validity of Hibernate\'s Criteria.list() and Query.list() methods returning multiple occurrences of the same entity?

4条回答
  •  一生所求
    2020-12-09 08:51

    If you have an object which has a list of sub objects on it, and your criteria joins the two tables together, you could potentially get duplicates of the main object.

    One way to ensure that you don't get duplicates is to use a DistinctRootEntityResultTransformer. The main drawback to this is if you are using result set buffering/row counting. The two don't work together.

提交回复
热议问题