Hi,

Is com.sample.entity.Account the entity type? I cannot recall if the
spec allows selecting new into the enhanced instance type, but it
certainly is not the intention, so that could be causing the problem.

Generally-speaking, if you find that you're doing a SELECT NEW into an
entity type, it probably means that you're fighting with OpenJPA --
SELECT NEW is generally meant for projection and aggregate data, not
as a means to obtain entity types. If you're doing so to achieve a
tuning optimization, you might want to consider OpenJPA's fetch plan
capabilities. Alternately, if you're just looking to load instances
from the database, you can simply change the query to 'SELECT x FROM
Account AS x'.

-Patrick

On 7/23/07, Prashant Bhat <[EMAIL PROTECTED]> wrote:
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



--
Patrick Linskey
202 669 5907

Reply via email to