How to use setResultTransformer in jpa
<p>How to use  criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); in the below code to remove duplicate rows ? </p>

<pre><code>JPATypedQueryVisitor&lt;Entity&gt; visitor = new JPATypedQueryVisitor&lt;Entity&gt;(
                getEntityManager(), getType());
        visitor.visit(sc);
        TypedQuery&lt;Entity&gt; typedQuery = null;
        typedQuery =visitor.getTypedQuery();

        return typedQuery.getResultList();


public TypedQuery&lt;T1&gt; getTypedQuery() {
        builder = em.getCriteriaBuilder();
        cq = builder.createQuery(Book.class);  
        return em.createQuery(cq); 
}
</code></pre>