0

I'm using Eclipselink (JPA) + GlassFish v3.1.2 + NetBeans 7.1.2

I have one table with composite primary key:

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;
}

Now.. how do I write SELECT MAX(with EmbeddedId) clause with JPQL ???

this fail...

Select MAX(e.IdMtoEnterprisePK.idMtoEnterpriseCode) From IdMtoEnterprise e

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].

jthmiranda
  • 73
  • 1
  • 7

1 Answers1

1

Your field is named idMtoEnterprisePK (lower-case i), and not IdMtoEnterprisePK (upper-case I).

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255