HHH-15160 - Add SPATIAL FunctionParameterType
This enables us to validate spatial arguments in functions.
This commit is contained in:
parent
2a1aa73319
commit
0327531c59
|
@ -39,6 +39,7 @@ import static org.hibernate.type.SqlTypes.isCharacterOrClobType;
|
||||||
import static org.hibernate.type.SqlTypes.isCharacterType;
|
import static org.hibernate.type.SqlTypes.isCharacterType;
|
||||||
import static org.hibernate.type.SqlTypes.isIntegral;
|
import static org.hibernate.type.SqlTypes.isIntegral;
|
||||||
import static org.hibernate.type.SqlTypes.isNumericType;
|
import static org.hibernate.type.SqlTypes.isNumericType;
|
||||||
|
import static org.hibernate.type.SqlTypes.isSpatialType;
|
||||||
import static org.hibernate.type.SqlTypes.isTemporalType;
|
import static org.hibernate.type.SqlTypes.isTemporalType;
|
||||||
|
|
||||||
|
|
||||||
|
@ -240,6 +241,10 @@ public class ArgumentTypesValidator implements ArgumentsValidator {
|
||||||
throwError(type, javaType, functionName, count);
|
throwError(type, javaType, functionName, count);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SPATIAL:
|
||||||
|
if ( !isSpatialType( code ) ) {
|
||||||
|
throwError( type, javaType, functionName, count );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,5 +82,10 @@ public enum FunctionParameterType {
|
||||||
/**
|
/**
|
||||||
* @see org.hibernate.type.SqlTypes#isCharacterOrClobType(int)
|
* @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
|
||||||
}
|
}
|
||||||
|
|
|
@ -752,4 +752,20 @@ public class SqlTypes {
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue