1 | initial version |
One solution to prevent repeated entities when using Criteria API for lazy associations fetch is to use the distinct
method of CriteriaQuery
. This will eliminate duplicates from the result set. Another solution is to use the fetch
method with the JoinType.LEFT
parameter, as it will only fetch the associated entities once. Additionally, you can also use the setResultTransformer
method to transform the result set into a customized format, which may eliminate duplicates as well.