> I am also using (I know, I know) subclass-based enhancement.
Have you tried with build time, or -javaagent enhancement?

Can you put together a small unit test?

Thanks,
Rick

On Tue, Oct 25, 2011 at 12:31 PM, Laird Nelson <ljnel...@gmail.com> wrote:

> We're using OpenJPA 2.1.0.
>
> I've got a case where I'm building a query like this:
>
> TypedQuery<SomeInterface> q = em.createNamedQuery("someQuery",
> SomeInterface.class);
>
> Now, SomeInterface is not the actual entity class--that would be
> SomeInterfaceEntity (not mentioned above, as you'll note).  But it is an
> interface that the results of the query all implement.
>
> EclipseLink and Hibernate both accept this declaration just fine and run
> the
> associated query just fine.
>
> At runtime, this version of OpenJPA seems to be trying to treat
> SomeInterface.class as though it denoted an entity:
>
> <openjpa-2.0.0-beta3-r422266:926797 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: Result type "interface
> com.foobar.SomeInterface" does not have any public fields or setter methods
> for the projection or aggregate result element "SomeInterfaceEntity", 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 null.
>    at org.apache.openjpa.kernel.ResultPacker.<init>(ResultPacker.java:158)
>    at org.apache.openjpa.kernel.ResultPacker.<init>(ResultPacker.java:103)
>    at
> org.apache.openjpa.kernel.QueryImpl.getResultPacker(QueryImpl.java:1289)
>    at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228)
>    at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
>    at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:861)
>    at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:792)
>    at
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
>    at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:288)
>    at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)
>
> Truth be told, I have no idea what OpenJPA is trying to tell me here.
>
> JPA's Javadoc places no restrictions on the class passed in as the second
> argument to EntityManager#createNamedQuery(String,
> Class)<
> http://download.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#createNamedQuery%28java.lang.String,%20java.lang.Class%29
> >.
> The JPA specification doesn't do so either, at least in the sections I read
> concerning queries.
>
> I am also using (I know, I know) subclass-based enhancement.
>
> What...are my options here?
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>



-- 
*Rick Curtis*

Reply via email to