Diego Gusava
Diego Gusava

Reputation: 125

Seam 2.2.2.Final new operator in EJBQL

i am having a problem with EntityQuery from Seam 2.2.2.Final, I can´t use the "new" operator in EJBQL,

"Select new com.ej.Prest(prest.id, prest.name) from Prest prest"

anyone has resolved this?

Upvotes: 1

Views: 195

Answers (1)

MikkolidisMedius
MikkolidisMedius

Reputation: 4844

If com.ej.Prest is a JPA entity, you don't need to use new, just query it:

select p from Prest p

or even:

from Prest

If it is not a JPA entity, then you cannot use it in the from clause, you need to use only JPA entities there. You can for example do (in this example, MyEntity is a JPA entity with name and surname properties used in the constructor for Prest:

select new com.ej.Prest(me.name, me.surname) from MyEntity me

Also, you need to define the constructor with the right arguments, in this case in com.ej.Prest:

public Prest(String name, String surname) {
  // constructor code here
}

Upvotes: 2

Related Questions