[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5023) Tuple selection with JPA 2.0 Criteria API fails (java.lang.ClassCastException: org.hibernate.ejb.criteria.expression.CompoundSelectionImpl cannot be cast to org.hibernate.ejb.criteria.expression.ExpressionImplementor)

atomicknight (JIRA) noreply at atlassian.com
Thu Mar 18 19:53:31 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5023?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35884#action_35884 ] 

atomicknight commented on HHH-5023:
-----------------------------------

Hmm, seems like the Hibernate bundle for Glassfish isn't actually the version it says it is. Manually replacing the Hibernate JAR with a known 3.5.0-CR-2 version seems to have fixed it.

Please close this issue (sorry for the inconvenience).

> Tuple selection with JPA 2.0 Criteria API fails (java.lang.ClassCastException: org.hibernate.ejb.criteria.expression.CompoundSelectionImpl cannot be cast to org.hibernate.ejb.criteria.expression.ExpressionImplementor)
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-5023
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5023
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.0-CR-2
>         Environment: Hibernate 3.5.0-CR-2
> PostgreSQL 8.4.1
> Glassfish v3 (build 74.2)
> JDK 1.6.0_18
>            Reporter: atomicknight
>         Attachments: jpa-test-eclipselink.war, jpa-test-hibernate.war, test.sql
>
>
> Attempting to select a Tuple using the JPA 2.0 Criteria API throws a ClassCastException.
> Example Java code:
> {noformat}
> public List<Tuple> selectTuple1( ) {
> 	CriteriaBuilder cb = em.getCriteriaBuilder( );
> 	CriteriaQuery<Tuple> cq = cb.createTupleQuery( );
> 	
> 	Root<TestEntity2> e2 = cq.from( TestEntity2.class );
> 	cq.multiselect( e2.get( "id" ), e2.get( "value" ) );
> 	
> 	TypedQuery<Tuple> query = em.createQuery( cq );
> 	return query.getResultList( );
> }
> {noformat} 
> Example stack trace:
> {noformat}
> javax.ejb.EJBException
> 	at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5070)
> 	at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4968)
> 	at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4756)
> 	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955)
> 	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1906)
> 	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:198)
> 	at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
> 	at $Proxy297.selectTuple1(Unknown Source)
> 	at com.example.__EJB31_Generated__JPABean__Intf____Bean__.selectTuple1(Unknown Source)
> 	at com.example.JPAServlet.doGet(JPAServlet.java:35)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
> 	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
> 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
> ...
> Caused by: java.lang.ClassCastException: org.hibernate.ejb.criteria.expression.CompoundSelectionImpl cannot be cast to org.hibernate.ejb.criteria.expression.ExpressionImplementor
> 	at org.hibernate.ejb.criteria.QueryStructure.render(QueryStructure.java:220)
> 	at org.hibernate.ejb.criteria.CriteriaQueryImpl.render(CriteriaQueryImpl.java:338)
> 	at org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:102)
> 	at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:158)
> 	at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:489)
> 	at com.example.JPABean.selectTuple1(JPABean.java:39)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> ...
> {noformat} 
> Other variations such as the following also throw the same exception:
> {noformat}
> cq.select( cb.tuple( e2.get( "id" ), e2.get( "value" ) ) );
> {noformat} 
> The same code works without issue using the EclipseLink persistence provider bundled with Glassfish v3.
> The test code is included in the attached WAR files. The two WAR files are identical except for the persistence provider configuration in persistence.xml. A dump of the PostgreSQL database is also included.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list