title: JPA native sql query mapping error?
body: <p>I have a JPA entity <code>MyEntity</code> which includes a composite primary key in a <code>@Embeddable</code> class <code>MyEntityPK</code>.<br/>
  I am using a native sql query in method <code>getThreeColumnsFromMyEntity()</code>:</p>
  
  <pre><code> public List&lt;MyEntity&gt; getThreeColumnsFromMyEntity() {
  
    List&lt;MyEntity&gt; results = em.createNativeQuery("select  pid,name,dateofbirth from (select pid,name, dateofbirth,max(dateofbirth) "
              + "over(partition by pid) latest_dateofbirth from my_entity_table) where"
              + " dateofbirth = latest_dateofbirth;","myEntityMapping").getResultList();
  
      return results;
  </code></pre>
  
  <p>My <code>@SqlResultSetMapping</code>:</p>
  
  <pre><code>@SqlResultSetMapping(
      name = "myEntityMapping",
      entities = {
          @EntityResult(
                  entityClass = MyEntityPK.class,
                  fields = {
                      @FieldResult(name = "PID", column = "pid"),
                      @FieldResult(name = "NAME", column = "name")}),
          @EntityResult(
                  entityClass = MyEntity.class,
                  fields = {
                      @FieldResult(name = "dateofbirth", column = "dateofbirth")})})
  </code></pre>
  
  <p>My JPA columns are named : <code>@Column(name="DATEOFBIRTH")</code>, <code>"PID"</code> and <code>"NAME"</code>.<br/>
  I tested my sql statement straight on the db and it works fine.<br/>
  When i run it on Eclipse I get an Oracle error:</p>
  
  <blockquote>
    <p>ORA-00911 and "Error code 911 , Query: ResultSetMappingQuery [..]</p>
  </blockquote>
  
  <p>My guess is there is something wrong with the mapping but I cannot find out what it is.</p>