title: Criteria API: query.from returns only null
body: <p>I'm pretty new to Criteria API, as a matter of fact I just pushed our latest project to JBoss 6 and JPA 2.0 just for the Criteria API.</p>
  
  <p>Now I am trying to get the easiest query running, but somehow without success:</p>
  
  <p>Without Criteria API it works without problems (Msv being my entity class):</p>
  
  <pre><code>Msv someMsv = manager.find(Msv.class, 1234L);
  System.out.println(someMsv);
  </code></pre>
  
  <p>The criteria stuff however does not give me any results from the DB:</p>
  
  <pre><code>CriteriaBuilder builder = manager.getCriteriaBuilder();
  CriteriaQuery&lt;Msv&gt; criteriaQuery = builder.createQuery(Msv.class);
  Root&lt;Msv&gt; from = criteriaQuery.from(Msv.class);
  // this returns null! /\
  Path&lt;Msv&gt; pk = from.get("PK_MSV_NR");
  Expression&lt;Boolean&gt; exp = builder.equal(pk, 1234L);
  CriteriaQuery&lt;Msv&gt; select = criteriaQuery.select(from).where(exp);
  [...]
  </code></pre>
  
  <p>When running the second code snipped I get a NullPointerException thrown on line 5 (Path pk ...), hence the above cireriaQuery.from returns null.</p>
  
  <p>Did I miss something essential, or what is the problem here? The first snippet is able to pull the correct entry from the DB and syso it, so I figured it is not a problem with my persistance config but rather with my Criteria API code. But that one I pulled from a tutorial basically line by line...</p>
  
  <p><em>Tech: I am using hibernate-3.6.6, hibernate-jpa-2.0-cr, jboss-as-6.0.0 and oracle11.</em></p>
  
  <p><strong>EDIT:</strong>
  Looked into this some more and discovered the following: it is not actually <em>criteriaQuery.from(...)</em> that produces null. The NullPointerException is not thrown because <em>.get()</em> is called on null, but is <em>actually thrown by/in .get() method</em>. I can for the life of me not see why however...</p>