title: How to wirte JPQL SELECT MAX with embedded id?
body: <p>I'm using Eclipselink (JPA) + GlassFish v3.1.2 + NetBeans 7.1.2</p>
  
  <p>I have one table with composite primary key:</p>
  
  <pre><code>table (Enterpirse)
  ----------------------
  |PK,FK idCompany     | nvarchar
  |PK idEnterprisecode | nvarchar
  |                    |
  |____________________|
  
  @Entity
  public class IdMtoEnterprise {
      @EmbeddedId
      protected IdMtoEnterprisePK idMtoEnterprisePK
  
      //getter and setter are omitted for clear
  }
  
  @Embeddable
  public class IdMtoEnterprisePK {
  
      @Column(name = "id_mto_company")
      private String idMtoCompany;
  
      @Column(name = "id_mto_enterprise_code")
      private String idMtoEnterpriseCode;
  }
  </code></pre>
  
  <p>Now.. how do I write SELECT MAX(with EmbeddedId)  clause with JPQL ???</p>
  
  <p>this fail...</p>
  
  <pre><code>Select MAX(e.IdMtoEnterprisePK.idMtoEnterpriseCode) From IdMtoEnterprise e
  </code></pre>
  
  <p>Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
  Exception Description: Error compiling the query [Select MAX(e.IdMtoEnterprisePK.idMtoEnterpriseCode) From IdMtoEnterprise e], line 1, column 13: unknown state or association field [IdMtoEnterprisePK] of class [com.sdn.entidad.IdMtoEnterprise].</p>