HHH-8454 corrected failing test for MySQL
This commit is contained in:
parent
91dace33b3
commit
a9e85716f1
|
@ -23,6 +23,8 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.test.criteria;
|
package org.hibernate.jpa.test.criteria;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Parameter;
|
import javax.persistence.Parameter;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
@ -31,11 +33,8 @@ import javax.persistence.criteria.ParameterExpression;
|
||||||
import javax.persistence.criteria.Path;
|
import javax.persistence.criteria.Path;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
@ -105,25 +104,24 @@ public class ParameterTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
// it causes a problem on Derby, which does not like the form "... where ? in (?,?)"
|
// it causes a problem on Derby, which does not like the form "... where ? in (?,?)"
|
||||||
// Derby wants one side or the other to be CAST (I assume so it can check typing).
|
// Derby wants one side or the other to be CAST (I assume so it can check typing).
|
||||||
|
|
||||||
// IMPL NOTE : currently this does not assert the format of the ultimate SQL. We'll let the matrix runs
|
|
||||||
// verify that the generated SQL is valid for each DB
|
|
||||||
|
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
CriteriaQuery<MultiTypedBasicAttributesEntity> criteria = em.getCriteriaBuilder()
|
CriteriaQuery<MultiTypedBasicAttributesEntity> criteria = em.getCriteriaBuilder()
|
||||||
.createQuery( MultiTypedBasicAttributesEntity.class );
|
.createQuery( MultiTypedBasicAttributesEntity.class );
|
||||||
criteria.from( MultiTypedBasicAttributesEntity.class );
|
criteria.from( MultiTypedBasicAttributesEntity.class );
|
||||||
|
|
||||||
|
// Note: Use chars here -- MySQL restricts the types that can be used within cast to a really limited
|
||||||
|
// subset. Char is one of the few.
|
||||||
criteria.where(
|
criteria.where(
|
||||||
em.getCriteriaBuilder().in( em.getCriteriaBuilder().parameter( Long.class, "p1" ) )
|
em.getCriteriaBuilder().in( em.getCriteriaBuilder().parameter( Character.class, "p1" ) )
|
||||||
.value( em.getCriteriaBuilder().parameter( Long.class, "p2" ) )
|
.value( em.getCriteriaBuilder().parameter( Character.class, "p2" ) )
|
||||||
.value( em.getCriteriaBuilder().parameter( Long.class, "p3" ) )
|
.value( em.getCriteriaBuilder().parameter( Character.class, "p3" ) )
|
||||||
);
|
);
|
||||||
|
|
||||||
TypedQuery<MultiTypedBasicAttributesEntity> query = em.createQuery( criteria );
|
TypedQuery<MultiTypedBasicAttributesEntity> query = em.createQuery( criteria );
|
||||||
query.setParameter( "p1", 1L );
|
query.setParameter( "p1", 'a' );
|
||||||
query.setParameter( "p2", 2L );
|
query.setParameter( "p2", 'b' );
|
||||||
query.setParameter( "p3", 3L );
|
query.setParameter( "p3", 'c' );
|
||||||
query.getResultList();
|
query.getResultList();
|
||||||
|
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
|
|
Loading…
Reference in New Issue