HHH-8454 added numeric types to MySQLDialect#getCastTypeName
This commit is contained in:
parent
a9e85716f1
commit
9f10ec5e74
|
@ -318,7 +318,13 @@ public class MySQLDialect extends Dialect {
|
||||||
public String getCastTypeName(int code) {
|
public String getCastTypeName(int code) {
|
||||||
switch ( code ) {
|
switch ( code ) {
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
|
case Types.BIGINT:
|
||||||
|
case Types.SMALLINT:
|
||||||
return "signed";
|
return "signed";
|
||||||
|
case Types.FLOAT:
|
||||||
|
case Types.NUMERIC:
|
||||||
|
case Types.REAL:
|
||||||
|
return "decimal";
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
return "char";
|
return "char";
|
||||||
case Types.VARBINARY:
|
case Types.VARBINARY:
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
@ -33,9 +31,12 @@ 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.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@ -110,18 +111,16 @@ public class ParameterTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
.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( Character.class, "p1" ) )
|
em.getCriteriaBuilder().in( em.getCriteriaBuilder().parameter( Long.class, "p1" ) )
|
||||||
.value( em.getCriteriaBuilder().parameter( Character.class, "p2" ) )
|
.value( em.getCriteriaBuilder().parameter( Long.class, "p2" ) )
|
||||||
.value( em.getCriteriaBuilder().parameter( Character.class, "p3" ) )
|
.value( em.getCriteriaBuilder().parameter( Long.class, "p3" ) )
|
||||||
);
|
);
|
||||||
|
|
||||||
TypedQuery<MultiTypedBasicAttributesEntity> query = em.createQuery( criteria );
|
TypedQuery<MultiTypedBasicAttributesEntity> query = em.createQuery( criteria );
|
||||||
query.setParameter( "p1", 'a' );
|
query.setParameter( "p1", 1L );
|
||||||
query.setParameter( "p2", 'b' );
|
query.setParameter( "p2", 2L );
|
||||||
query.setParameter( "p3", 'c' );
|
query.setParameter( "p3", 3L );
|
||||||
query.getResultList();
|
query.getResultList();
|
||||||
|
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
|
|
Loading…
Reference in New Issue