title: How to resolve Oracle's 'rownum' pseudocolumn with JPA Criteria API?
body: <p>I would like to get first row from database using JPA Criteria. I use JPA, Hibernate 4.2.7.
  In SQL, statement looks like:</p>
  
  <pre><code>SELECT * FROM houses WHERE rownum = 1;
  </code></pre>
  
  <p>My Java code to achive that looks like:</p>
  
  <pre><code>    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
      CriteriaQuery&lt;House&gt; query = builder.createQuery(House.class);
      Root&lt;House&gt; root = query.from(House.class);
  
      query.select(root).where(builder.equal(root.get("rownum"), 1));
  
      TypedQuery&lt;House&gt; tQuery = entityManager.createQuery(query); 
      House house = tQuery.getSingleResult();
  </code></pre>
  
  <p>But 'rownum' pseudocolumn cannot be resolved, I get exception:</p>
  
  <pre><code> java.lang.IllegalArgumentException: Unable to resolve attribute [rownum] against path
  at org.hibernate.ejb.criteria.path.AbstractPathImpl.unknownAttribute(AbstractPathImpl.java:120)
  at org.hibernate.ejb.criteria.path.AbstractPathImpl.locateAttribute(AbstractPathImpl.java:229)
  at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:200)
  </code></pre>
  
  <p>Is is possible, and if so, how to get 'rownum' pseudocolumn with Criteria API? Thanks for any suggestions.</p>