Search code examples
javajpatoplinktoplink-essentials

JPA constructor class [Emp] not found - oracle.toplink.essentials.exceptions.EJBQLException


This is in continuation of this question

I have namedQuery as

select new Emp(o.empNo, o.empName)  from Emp o

and constructor defined as

public Emp(String empNo, String empName) {
    this.empNo= empNo;
    this.empName= empName;
}

I am getting error when I execute

Exception [TOPLINK-8013] (Oracle TopLink Essentials - 2.1 
(Build b52-fcs (09/24/2008))):
oracle.toplink.essentials.exceptions.EJBQLException
Exception Description: Error compiling the query [Emp.findAll:
select new Emp(o.empNo, o.empName)  from Emp o ], line 1, column 9: 
constructor class [Emp] not found.

Solution

  • http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/jpa_langref.html#jpa_langref_constructor

    A constructor may be used in the SELECT list to return one or more Java instances. The specified class is not required to be an entity or to be mapped to the database. The constructor name must be fully qualified.

    SELECT NEW com.company.PublisherInfo(pub.id, pub.revenue, mag.price)