title: how to write subquery using criteria builder
body: <p>Here Iam using NativeQuery to perform selecting lookuptype using subquery this is working right but I want to use Criteria Builder  how i can use    </p>
  
  <p><code>Query query = em.createNativeQuery("SELECT * FROM LOOKUPMASTER WHERE PARENTLOOKUPTYPEID = (SELECT LOOKUPID FROM LOOKUPMASTER WHERE LOOKUPTYPE =? ) ", Lookupmaster.class);
              query.setParameter(1, lookUpType);</code></p>
  
  <p>I tried to write the above query using criteria builder but i am getting different result here is my criteria query</p>
  
  <pre><code>`CriteriaBuilder cb =em.getCriteriaBuilder();
          CriteriaQuery cq=cb.createQuery(Lookupmaster.class);
          Root&lt;Lookupmaster&gt; rt=cq.from(Lookupmaster.class);
          Path&lt;Object&gt; path = rt.get("parentlookuptypeid");
          cq.select(rt);
          Subquery&lt;Lookupmaster&gt; subquery = cq.subquery(Lookupmaster.class);
          Root rt1 = subquery.from(Lookupmaster.class);
          subquery.select(rt1.get("lookupid"));
          subquery.where(cb.equal(rt.get("lookuptype"),lookUpType));
  
          cq.where(cb.in(path).value(subquery));
          Query qry =em.createQuery(cq)`
  </code></pre>