diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/ArgumentTypesValidator.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/ArgumentTypesValidator.java index 456f552f3e..ab84ccc18a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/ArgumentTypesValidator.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/ArgumentTypesValidator.java @@ -39,6 +39,7 @@ import static org.hibernate.type.SqlTypes.isCharacterOrClobType; import static org.hibernate.type.SqlTypes.isCharacterType; import static org.hibernate.type.SqlTypes.isIntegral; import static org.hibernate.type.SqlTypes.isNumericType; +import static org.hibernate.type.SqlTypes.isSpatialType; import static org.hibernate.type.SqlTypes.isTemporalType; @@ -240,6 +241,10 @@ public class ArgumentTypesValidator implements ArgumentsValidator { throwError(type, javaType, functionName, count); } break; + case SPATIAL: + if ( !isSpatialType( code ) ) { + throwError( type, javaType, functionName, count ); + } } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/FunctionParameterType.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/FunctionParameterType.java index dca2deb65b..d62924c3e8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/FunctionParameterType.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/FunctionParameterType.java @@ -82,5 +82,10 @@ public enum FunctionParameterType { /** * @see org.hibernate.type.SqlTypes#isCharacterOrClobType(int) */ - STRING_OR_CLOB + STRING_OR_CLOB, + /** + * Indicates that the argument should be a spatial type + * @see org.hibernate.type.SqlTypes#isSpatialType(int) + */ + SPATIAL } diff --git a/hibernate-core/src/main/java/org/hibernate/type/SqlTypes.java b/hibernate-core/src/main/java/org/hibernate/type/SqlTypes.java index 03c5eaab1f..47ea541af1 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/SqlTypes.java +++ b/hibernate-core/src/main/java/org/hibernate/type/SqlTypes.java @@ -752,4 +752,20 @@ public class SqlTypes { return false; } } + + /** + * Does the typecode represent a spatial (Geometry or Geography) type. + * + * @param typeCode - a JDBC type code + */ + public static boolean isSpatialType(int typeCode) { + switch ( typeCode ) { + case GEOMETRY: + case POINT: + case GEOGRAPHY: + return true; + default: + return false; + } + } }