HHH-15160 - Add SPATIAL FunctionParameterType

This enables us to validate spatial arguments in functions.
This commit is contained in:
Karel Maesen 2023-04-27 21:37:50 +02:00 committed by Christian Beikov
parent 2a1aa73319
commit 0327531c59
3 changed files with 27 additions and 1 deletions

View File

@ -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 );
}
}
}

View File

@ -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
}

View File

@ -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;
}
}
}