Hi,

I've an Account entity with a default constructor and another with
parameters as shown below.
With this query, I'm getting the following exception,(although the
constructor is available)

SELECT NEW com.sample.entity.Account(x.id, x.accountNumber, x.name,
x.accountType, x.currentBalance) FROM Account AS x

<0.0.0 nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
Result type "class com.sample.entity.Account" does not have any public
fields or setter methods for the projection or aggregate result element
"jpqlalias1", nor does it have a generic put(Object,Object) method that can
be used, nor does it have a public constructor that takes the types [long,
class java.lang.String, class java.lang.String, class
com.sample.entity.AccountType, class java.math.BigDecimal].
   at org.apache.openjpa.kernel.ResultPacker.<init>(ResultPacker.java:139)
   at org.apache.openjpa.kernel.ResultPacker.<init>(ResultPacker.java:102)
   at org.apache.openjpa.kernel.QueryImpl.getResultPacker(QueryImpl.java
:1255)
   at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1205)
   at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:989)
   at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:798)
   at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:768)
   at org.apache.openjpa.kernel.DelegatingQuery.execute(
DelegatingQuery.java:533)
   at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:227)
   at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java
:269)
   at org.springframework.orm.jpa.JpaTemplate$9.doInJpa(JpaTemplate.java
:313)
   at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:191)
   at org.springframework.orm.jpa.JpaTemplate.executeFind(JpaTemplate.java
:158)
   at org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:305)

Is the query syntax not correct or Am I missing any configuration?

Thanks,
Prashant

PS. I'm using latest snapshots of OpenJPA with Spring-2.0.6 and H2 Database

Reply via email to