[ 
https://issues.apache.org/jira/browse/OPENJPA-2065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13136242#comment-13136242
 ] 

Kevin Sutter commented on OPENJPA-2065:
---------------------------------------

Laird,
This does look to be a valid request, but I don't think it's a spec compliance 
issue.  According to section 2.11.3, non-entity classes (interfaces) can not be 
passed as arguments to EM and Query methods:

"Non-entity classes cannot be passed as arguments to methods of the 
EntityManager or Query
interfaces[24] and cannot bear mapping information."

An easy work around for now is to not utilize the TypedQuery support and cast 
the results instead.  Not great, but it's workable until a better solution is 
developed.

BTW, having both EclipseLink and Hibernate support this does add to the weight 
of resolving this JIRA...  :-)

Thanks,
Kevin
                
> JPA 2.0 Spec. Violation? EntityManager#createNamedQuery(String, Class) bombs 
> with non-entity Class parameter
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2065
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2065
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.0, 2.1.1
>            Reporter: Laird Nelson
>              Labels: specification
>
> Suppose we have an interface, A.
> Suppose we have a JPA-compliant entity class, B, that implements A.
> This construction will fail at runtime:
> final TypedQuery<A> q = em.createNamedQuery("someNamedQuery", A.class);
> Hibernate and EclipseLink both accept this construction.
> I don't see anywhere in the JPA specification that the class parameter must 
> denote an entity type.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to