title: JPA/Metamodel: Strange (inconsistent ?) example in Sun Docs
body: <p>In <a href="http://docs.sun.com/app/docs/doc/821-1841/gjiup?l=en&amp;a=view" rel="nofollow noreferrer">Sun Online resources</a>, they provide son example about the usage of the Criteria/Metamodel API, but as far as I understand Java, it seems to be impossible to work:</p>
  
  <pre><code>CriteriaQuery&lt;Pet&gt; cq = cb.createQuery(Pet.class);
  Metamodel m = em.getMetamodel();
  EntityType&lt;Pet&gt; Pet_ = m.entity(Pet.class);
  EntityType&lt;Owner&gt; Owner_ = m.entity(Owner.class);
  
  Root&lt;Pet&gt; pet = cq.from(Pet.class);
  Join&lt;Owner, Address&gt; address = cq.join(**Pet_.owners**).join(**Owner_.addresses**);
  </code></pre>
  
  <p><code>Pet_</code> is a <em>instance</em> of class  <a href="http://download.oracle.com/javaee/6/api/javax/persistence/metamodel/EntityType.html" rel="nofollow noreferrer"><code>EntityType</code></a> which <strong>doesn't</strong> define any attribute named <code>owners</code> or <code>addresses</code>.</p>
  
  <p>They do define classes named <code>Pet_</code> and <code>Owner_</code> for the metamodel, but they importation here would create a conflict with the variable names ... Am I right?</p>
  
  <p>__</p>
  
  <p>(the question is also related to this <a href="https://stackoverflow.com/questions/3854687/jpa-hibernate-static-metamodel-attributes-not-populated-nullpointerexception">one</a>)</p>