如何使用criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);在下面的代码中删除重复的行?
JPATypedQueryVisitor<Entity> visitor = new JPATypedQueryVisitor<Entity>(
getEntityManager(), getType());
visitor.visit(sc);
TypedQuery<Entity> typedQuery = null;
typedQuery =visitor.getTypedQuery();
return typedQuery.getResultList();
public TypedQuery<T1> getTypedQuery() {
builder = em.getCriteriaBuilder();
cq = builder.createQuery(Book.class);
return em.createQuery(cq);
}