[Hibernate-JIRA] Created: (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)
by atomicknight (JIRA)
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 7 months
[Hibernate-JIRA] Created: (HHH-5022) Small documentation improvements in chapter 6
by Sorin Postelnicu (JIRA)
Small documentation improvements in chapter 6
---------------------------------------------
Key: HHH-5022
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5022
Project: Hibernate Core
Issue Type: Improvement
Components: documentation
Affects Versions: 3.3.2
Reporter: Sorin Postelnicu
Priority: Minor
In section 6.2.3, I think it would be clearer/more correct if the final phrase would be like this: "A bag does not retain its order when it is persisted to the database, but it can be optionally sorted or ordered when it is retrieved from the database."
Also, at the end of section 14.3, before the paragraph with "The fetch construct cannot be used in queries called using...", it would be good if you add something like: "<strong>Limitations:</strong>", so that people can easily spot them in the documentation and be aware of them.
And also the correct sentence should be "Fetch should NOT be used together with setMaxResults() or setFirstResult(), as these operations..." - this is a minor typo, but with major implications :)
(I know that these are some of the frequent issues encountered by people who are just learning or have little experience with Hibernate)
Also some small typos:
In section 14.16:
select usr.id, usr.name
from User usr.name
join usr.messages msg
group by usr.id, usr.name
having count(msg) >= 1
should be
select usr.id, usr.name
from User usr
join usr.messages msg
group by usr.id, usr.name
having count(msg) >= 1
And in section 4.4:
Session s = openSession();
Transaction tx = s.beginTransaction();
Session s = openSession();
should be
Session s = openSession();
Transaction tx = s.beginTransaction();
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 7 months
[Hibernate-JIRA] Created: (HV-288) The validator doesn't validate correctly groups composing a group sequence
by Igor Leboroni (JIRA)
The validator doesn't validate correctly groups composing a group sequence
--------------------------------------------------------------------------
Key: HV-288
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-288
Project: Hibernate Validator
Issue Type: Bug
Components: engine
Affects Versions: 4.0.2.GA
Environment: Sun JVM - 1.6
Reporter: Igor Leboroni
Assignee: Hardy Ferentschik
I have the following class.
{code}
public class Try {
@NotNull(groups=BaseComponent.class)
private int field1;
@NotNull(groups=Component.class)
private int field2;
@NotNull(groups=OtherComponent.class)
private int field3;
public interface BaseComponent {}
public interface Component extends BaseComponent{}
public interface OtherComponent {}
@GroupSequence({Component.class, OtherComponent.class})
public interface GlobalCheck {}
}
{code}
Invoking the validation on the group GlobalCheck results in the check of the NotNull constraint on field2 and field3 (if the field2 validation is passed). The NotNull field1's constraint isn't evaluated. In fact every constraint that belongs to a group parent of one of the groups composing the group sequence isn't evaluated at all.
I think the problem is in the {{org.hibernate.validator.engine.ValidatorImpl validateInContext(U value, GlobalExecutionContext<T> context, GroupChain groupChain, PathImpl path)}} method, when group sequences are evaluated.
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 7 months