HHH-12426 - SAP HANA spatial dialect should support all SAP HANA spatial functions
This commit is contained in:
parent
fbe32f162a
commit
8c661baea2
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.spatial.dialect.hana;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.dialect.HANAColumnStoreDialect;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
|
@ -29,88 +31,226 @@ public class HANASpatialDialect extends HANAColumnStoreDialect implements Spatia
|
|||
registerColumnType( HANAGeometryTypeDescriptor.INSTANCE.getSqlType(), "ST_GEOMETRY" );
|
||||
registerColumnType( HANAPointTypeDescriptor.INSTANCE.getSqlType(), "ST_POINT" );
|
||||
|
||||
registerHibernateType( Types.OTHER, new GeolatteGeometryType( HANAGeometryTypeDescriptor.INSTANCE ).getName() );
|
||||
|
||||
/*
|
||||
* Hibernate Spatial functions
|
||||
*/
|
||||
registerFunction(
|
||||
SpatialFunction.asbinary.name(),
|
||||
new HANASpatialFunction( "ST_AsBinary", StandardBasicTypes.MATERIALIZED_BLOB, false )
|
||||
);
|
||||
new HANASpatialFunction( "ST_AsBinary", StandardBasicTypes.MATERIALIZED_BLOB, false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.astext.name(),
|
||||
new HANASpatialFunction( "ST_AsText", StandardBasicTypes.MATERIALIZED_CLOB, false )
|
||||
);
|
||||
new HANASpatialFunction( "ST_AsText", StandardBasicTypes.MATERIALIZED_CLOB, false ) );
|
||||
registerFunction( SpatialFunction.boundary.name(), new HANASpatialFunction( "ST_Boundary", false ) );
|
||||
registerFunction( SpatialFunction.buffer.name(), new HANASpatialFunction( "ST_Buffer", false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.contains.name(),
|
||||
new HANASpatialFunction( "ST_Contains", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Contains", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction( SpatialFunction.convexhull.name(), new HANASpatialFunction( "ST_ConvexHull", false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.crosses.name(),
|
||||
new HANASpatialFunction( "ST_Crosses", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Crosses", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction( SpatialFunction.difference.name(), new HANASpatialFunction( "ST_Difference", true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.dimension.name(),
|
||||
new HANASpatialFunction( "ST_Dimension ", StandardBasicTypes.INTEGER, false )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Dimension", StandardBasicTypes.INTEGER, false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.disjoint.name(),
|
||||
new HANASpatialFunction( "ST_Disjoint", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Disjoint", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.distance.name(),
|
||||
new HANASpatialFunction( "ST_Distance", StandardBasicTypes.DOUBLE, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Distance", StandardBasicTypes.DOUBLE, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.dwithin.name(),
|
||||
new HANASpatialFunction( "ST_WithinDistance", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_WithinDistance", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction( SpatialFunction.envelope.name(), new HANASpatialFunction( "ST_Envelope", true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.equals.name(),
|
||||
new HANASpatialFunction( "ST_Equals", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Equals", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction( SpatialFunction.extent.name(), new HANASpatialAggregate( "ST_EnvelopeAggr" ) );
|
||||
registerFunction(
|
||||
SpatialFunction.geometrytype.name(),
|
||||
new HANASpatialFunction( "ST_GeometryType", StandardBasicTypes.STRING, false )
|
||||
);
|
||||
new HANASpatialFunction( "ST_GeometryType", StandardBasicTypes.STRING, false ) );
|
||||
registerFunction( SpatialFunction.geomunion.name(), new HANASpatialFunction( "ST_Union", true ) );
|
||||
registerFunction( SpatialFunction.intersection.name(), new HANASpatialFunction( "ST_Intersection", true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.intersects.name(),
|
||||
new HANASpatialFunction( "ST_Intersects", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Intersects", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.isempty.name(),
|
||||
new HANASpatialFunction( "ST_IsEmpty", StandardBasicTypes.NUMERIC_BOOLEAN, false )
|
||||
);
|
||||
new HANASpatialFunction( "ST_IsEmpty", StandardBasicTypes.NUMERIC_BOOLEAN, false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.issimple.name(),
|
||||
new HANASpatialFunction( "ST_IsSimple", StandardBasicTypes.NUMERIC_BOOLEAN, false )
|
||||
);
|
||||
new HANASpatialFunction( "ST_IsSimple", StandardBasicTypes.NUMERIC_BOOLEAN, false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.overlaps.name(),
|
||||
new HANASpatialFunction( "ST_Overlaps", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Overlaps", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.relate.name(),
|
||||
new HANASpatialFunction( "ST_Relate", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Relate", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.srid.name(),
|
||||
new HANASpatialFunction( "ST_SRID", StandardBasicTypes.INTEGER, false )
|
||||
);
|
||||
new HANASpatialFunction( "ST_SRID", StandardBasicTypes.INTEGER, false ) );
|
||||
registerFunction( SpatialFunction.symdifference.name(), new HANASpatialFunction( "ST_SymDifference", true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.touches.name(),
|
||||
new HANASpatialFunction( "ST_Touches", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Touches", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction( SpatialFunction.transform.name(), new HANASpatialFunction( "ST_Transform", false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.within.name(),
|
||||
new HANASpatialFunction( "ST_Within", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
new HANASpatialFunction( "ST_Within", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
|
||||
/*
|
||||
* Additional HANA functions
|
||||
*/
|
||||
registerFunction( HANASpatialFunctions.alphashape.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.alphashape.getFunctionName(), false ) );
|
||||
registerFunction( HANASpatialFunctions.area.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.area.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction( HANASpatialFunctions.asewkb.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.asewkb.getFunctionName(), StandardBasicTypes.MATERIALIZED_BLOB, false ) );
|
||||
registerFunction( HANASpatialFunctions.asewkt.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.asewkt.getFunctionName(), StandardBasicTypes.MATERIALIZED_CLOB, false ) );
|
||||
registerFunction( HANASpatialFunctions.asgeojson.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.asgeojson.getFunctionName(), StandardBasicTypes.MATERIALIZED_CLOB, false ) );
|
||||
registerFunction( HANASpatialFunctions.assvg.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.assvg.getFunctionName(), StandardBasicTypes.MATERIALIZED_CLOB, false ) );
|
||||
registerFunction( HANASpatialFunctions.assvgaggr.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.assvgaggr.getFunctionName(), StandardBasicTypes.MATERIALIZED_CLOB, false, true ) );
|
||||
registerFunction( HANASpatialFunctions.aswkb.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.aswkb.getFunctionName(), StandardBasicTypes.MATERIALIZED_BLOB, false ) );
|
||||
registerFunction( HANASpatialFunctions.aswkt.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.aswkt.getFunctionName(), StandardBasicTypes.MATERIALIZED_CLOB, false ) );
|
||||
registerFunction( HANASpatialFunctions.centroid.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.centroid.getFunctionName(), false ) );
|
||||
registerFunction( HANASpatialFunctions.convexhullaggr.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.convexhullaggr.getFunctionName(), true, true ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.coorddim.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.coorddim.getFunctionName(), StandardBasicTypes.INTEGER, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.coveredby.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.coveredby.getFunctionName(), StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.covers.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.covers.getFunctionName(), StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.endpoint.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.endpoint.getFunctionName(), false ) );
|
||||
registerFunction( HANASpatialFunctions.envelopeaggr.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.envelopeaggr.getFunctionName(), true, true ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.exteriorring.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.exteriorring.getFunctionName(), false ) );
|
||||
registerFunction( HANASpatialFunctions.geomfromewkb.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.geomfromewkb.getFunctionName(), false, true ) );
|
||||
registerFunction( HANASpatialFunctions.geomfromewkt.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.geomfromewkt.getFunctionName(), false, true ) );
|
||||
registerFunction( HANASpatialFunctions.geomfromtext.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.geomfromtext.getFunctionName(), false, true ) );
|
||||
registerFunction( HANASpatialFunctions.geomfromwkb.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.geomfromwkb.getFunctionName(), false, true ) );
|
||||
registerFunction( HANASpatialFunctions.geomfromwkt.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.geomfromwkt.getFunctionName(), false, true ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.geometryn.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.geometryn.getFunctionName(), false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.interiorringn.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.interiorringn.getFunctionName(), false ) );
|
||||
registerFunction( HANASpatialFunctions.intersectionaggr.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.intersectionaggr.getFunctionName(), true, true ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.intersectsrect.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.intersectsrect.getFunctionName(), StandardBasicTypes.NUMERIC_BOOLEAN,
|
||||
new boolean[]{ true, true } ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.is3d.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.is3d.getFunctionName(), StandardBasicTypes.NUMERIC_BOOLEAN, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.isclosed.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.isclosed.getFunctionName(), StandardBasicTypes.NUMERIC_BOOLEAN, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.ismeasured.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.ismeasured.getFunctionName(), StandardBasicTypes.NUMERIC_BOOLEAN, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.isring.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.isring.getFunctionName(), StandardBasicTypes.NUMERIC_BOOLEAN, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.isvalid.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.isvalid.getFunctionName(), StandardBasicTypes.NUMERIC_BOOLEAN, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.length.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.length.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.m.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.m.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.mmax.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.mmax.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.mmin.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.mmin.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.numgeometries.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.numgeometries.getFunctionName(), StandardBasicTypes.INTEGER, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.numinteriorring.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.numinteriorring.getFunctionName(), StandardBasicTypes.INTEGER, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.numinteriorrings.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.numinteriorrings.getFunctionName(), StandardBasicTypes.INTEGER, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.numpoints.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.numpoints.getFunctionName(), StandardBasicTypes.INTEGER, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.orderingequals.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.orderingequals.getFunctionName(), StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.perimeter.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.perimeter.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.pointonsurface.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.pointonsurface.getFunctionName(), false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.pointn.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.pointn.getFunctionName(), false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.snaptogrid.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.snaptogrid.getFunctionName(), false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.startpoint.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.startpoint.getFunctionName(), false ) );
|
||||
registerFunction( HANASpatialFunctions.unionaggr.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.unionaggr.getFunctionName(), true, true ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.x.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.x.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.xmax.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.xmax.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.xmin.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.xmin.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.y.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.y.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.ymax.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.ymax.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.ymin.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.ymin.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.z.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.z.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.zmax.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.zmax.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
registerFunction(
|
||||
HANASpatialFunctions.zmin.name(),
|
||||
new HANASpatialFunction( HANASpatialFunctions.zmin.getFunctionName(), StandardBasicTypes.DOUBLE, false ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,8 +294,7 @@ public class HANASpatialDialect extends HANAColumnStoreDialect implements Spatia
|
|||
}
|
||||
|
||||
},
|
||||
Boolean.FALSE
|
||||
).booleanValue();
|
||||
Boolean.FALSE ).booleanValue();
|
||||
|
||||
if ( determineCrsIdFromDatabase ) {
|
||||
typeContributions.contributeType( new GeolatteGeometryType( HANAGeometryTypeDescriptor.CRS_LOADING_INSTANCE ) );
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.spatial.dialect.hana;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||
|
@ -16,16 +17,39 @@ public class HANASpatialFunction extends StandardSQLFunction {
|
|||
|
||||
private static final String AS_EWKB_SUFFIX = ".ST_AsEWKB()";
|
||||
|
||||
private final boolean firstArgumentIsGeometryType;
|
||||
private final BitSet argumentIsGeometryTypeMask = new BitSet();
|
||||
private final boolean staticFunction;
|
||||
|
||||
public HANASpatialFunction(String name, boolean firstArgumentIsGeometryType) {
|
||||
super( name );
|
||||
this.firstArgumentIsGeometryType = firstArgumentIsGeometryType;
|
||||
this.argumentIsGeometryTypeMask.set( 1, firstArgumentIsGeometryType );
|
||||
this.staticFunction = false;
|
||||
}
|
||||
|
||||
public HANASpatialFunction(String name, boolean firstArgumentIsGeometryType, boolean staticFunction) {
|
||||
super( name );
|
||||
this.argumentIsGeometryTypeMask.set( staticFunction ? 0 : 1, firstArgumentIsGeometryType );
|
||||
this.staticFunction = staticFunction;
|
||||
}
|
||||
|
||||
public HANASpatialFunction(String name, Type registeredType, boolean firstArgumentIsGeometryType) {
|
||||
super( name, registeredType );
|
||||
this.firstArgumentIsGeometryType = firstArgumentIsGeometryType;
|
||||
this.argumentIsGeometryTypeMask.set( 1, firstArgumentIsGeometryType );
|
||||
this.staticFunction = false;
|
||||
}
|
||||
|
||||
public HANASpatialFunction(String name, Type registeredType, boolean[] argumentIsGeometryTypeMask) {
|
||||
super( name, registeredType );
|
||||
for ( int i = 0; i < argumentIsGeometryTypeMask.length; i++ ) {
|
||||
this.argumentIsGeometryTypeMask.set( i + 1, argumentIsGeometryTypeMask[i] );
|
||||
}
|
||||
this.staticFunction = false;
|
||||
}
|
||||
|
||||
public HANASpatialFunction(String name, Type registeredType, boolean firstArgumentIsGeometryType, boolean staticFunction) {
|
||||
super( name, registeredType );
|
||||
this.argumentIsGeometryTypeMask.set( staticFunction ? 0 : 1, firstArgumentIsGeometryType );
|
||||
this.staticFunction = staticFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,18 +59,30 @@ public class HANASpatialFunction extends StandardSQLFunction {
|
|||
}
|
||||
else {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
// If the first argument is an expression, e.g. a nested function, strip the .ST_AsEWKB() suffix
|
||||
buf.append( stripEWKBSuffix( arguments.get( 0 ) ) );
|
||||
int firstArgumentIndex;
|
||||
if ( staticFunction ) {
|
||||
// Add function call
|
||||
buf.append( getName() );
|
||||
firstArgumentIndex = 0;
|
||||
}
|
||||
else {
|
||||
// If the first argument is an expression, e.g. a nested function, strip the .ST_AsEWKB() suffix
|
||||
buf.append( stripEWKBSuffix( arguments.get( 0 ) ) );
|
||||
|
||||
// Add function call
|
||||
buf.append( "." ).append( getName() ).append( '(' );
|
||||
// Add function call
|
||||
buf.append( "." ).append( getName() );
|
||||
|
||||
firstArgumentIndex = 1;
|
||||
}
|
||||
|
||||
buf.append( '(' );
|
||||
|
||||
// Add function arguments
|
||||
for ( int i = 1; i < arguments.size(); i++ ) {
|
||||
for ( int i = firstArgumentIndex; i < arguments.size(); i++ ) {
|
||||
final Object argument = arguments.get( i );
|
||||
// Check if first argument needs to be parsed from EWKB. This is the case if the first argument is a
|
||||
// parameter that is set as EWKB or if it's a nested function call.
|
||||
final boolean parseFromWKB = ( this.firstArgumentIsGeometryType && i == 1 && "?".equals( argument ) );
|
||||
final boolean parseFromWKB = ( isGeometryArgument( i ) && "?".equals( argument ) );
|
||||
if ( parseFromWKB ) {
|
||||
buf.append( "ST_GeomFromEWKB(" );
|
||||
}
|
||||
|
@ -75,4 +111,8 @@ public class HANASpatialFunction extends StandardSQLFunction {
|
|||
|
||||
return argument;
|
||||
}
|
||||
|
||||
private boolean isGeometryArgument(int idx) {
|
||||
return this.argumentIsGeometryTypeMask.size() > idx && this.argumentIsGeometryTypeMask.get( idx );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.spatial.dialect.hana;
|
||||
|
||||
public enum HANASpatialFunctions {
|
||||
alphashape("ST_AlphaShape"),
|
||||
|
||||
area("ST_Area"),
|
||||
|
||||
asewkb("ST_AsEWKB"),
|
||||
|
||||
asewkt("ST_AsEWKT"),
|
||||
|
||||
asgeojson("ST_AsGeoJSON"),
|
||||
|
||||
assvg("ST_AsSVG"),
|
||||
|
||||
assvgaggr("ST_AsSVGAggr"),
|
||||
|
||||
aswkb("ST_AsWKB"),
|
||||
|
||||
aswkt("ST_AsWKT"),
|
||||
|
||||
centroid("ST_Centroid"),
|
||||
|
||||
convexhullaggr("ST_ConvexHullAggr"),
|
||||
|
||||
coorddim("ST_CoordDim"),
|
||||
|
||||
coveredby("ST_CoveredBy"),
|
||||
|
||||
covers("ST_Covers"),
|
||||
|
||||
endpoint("ST_EndPoint"),
|
||||
|
||||
envelopeaggr("ST_EnvelopeAggr"),
|
||||
|
||||
exteriorring("ST_ExteriorRing"),
|
||||
|
||||
geomfromewkb("ST_GeomFromEWKB"),
|
||||
|
||||
geomfromewkt("ST_GeomFromEWKT"),
|
||||
|
||||
geomfromtext("ST_GeomFromText"),
|
||||
|
||||
geomfromwkb("ST_GeomFromWKB"),
|
||||
|
||||
geomfromwkt("ST_GeomFromWKT"),
|
||||
|
||||
geometryn("ST_GeometryN"),
|
||||
|
||||
interiorringn("ST_InteriorRingN"),
|
||||
|
||||
intersectionaggr("ST_IntersectionAggr"),
|
||||
|
||||
intersectsrect("ST_IntersectsRect"),
|
||||
|
||||
is3d("ST_Is3D"),
|
||||
|
||||
isclosed("ST_IsClosed"),
|
||||
|
||||
ismeasured("ST_IsMeasured"),
|
||||
|
||||
isring("ST_IsRing"),
|
||||
|
||||
isvalid("ST_IsValid"),
|
||||
|
||||
length("ST_Length"),
|
||||
|
||||
m("ST_M"),
|
||||
|
||||
mmax("ST_MMax"),
|
||||
|
||||
mmin("ST_MMin"),
|
||||
|
||||
numgeometries("ST_NumGeometries"),
|
||||
|
||||
numinteriorring("ST_NumInteriorRing"),
|
||||
|
||||
numinteriorrings("ST_NumInteriorRings"),
|
||||
|
||||
numpoints("ST_NumPoints"),
|
||||
|
||||
orderingequals("ST_OrderingEquals"),
|
||||
|
||||
perimeter("ST_Perimeter"),
|
||||
|
||||
pointonsurface("ST_PointOnSurface"),
|
||||
|
||||
pointn("ST_PointN"),
|
||||
|
||||
snaptogrid("ST_SnapToGrid"),
|
||||
|
||||
startpoint("ST_StartPoint"),
|
||||
|
||||
unionaggr("ST_UnionAggr"),
|
||||
|
||||
x("ST_X"),
|
||||
|
||||
xmax("ST_XMax"),
|
||||
|
||||
xmin("ST_XMin"),
|
||||
|
||||
y("ST_Y"),
|
||||
|
||||
ymax("ST_YMax"),
|
||||
|
||||
ymin("ST_YMin"),
|
||||
|
||||
z("ST_Z"),
|
||||
|
||||
zmax("ST_ZMax"),
|
||||
|
||||
zmin("ST_ZMin");
|
||||
|
||||
private final String functionName;
|
||||
|
||||
private HANASpatialFunctions(String functionName) {
|
||||
this.functionName = functionName;
|
||||
}
|
||||
|
||||
public String getFunctionName() {
|
||||
return functionName;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -18,11 +18,13 @@ import org.hibernate.criterion.Criterion;
|
|||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
import org.hibernate.spatial.criterion.SpatialRestrictions;
|
||||
import org.hibernate.spatial.dialect.hana.HANASpatialDialect;
|
||||
import org.hibernate.spatial.integration.jts.GeomEntity;
|
||||
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
||||
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.Skip;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -31,6 +33,7 @@ import static junit.framework.Assert.assertEquals;
|
|||
import static org.junit.Assert.fail;
|
||||
|
||||
@Skip(condition = SpatialDialectMatcher.class, message = "No Spatial Dialect")
|
||||
@SkipForDialect(value = HANASpatialDialect.class, comment = "The HANA dialect is tested via org.hibernate.spatial.dialect.hana.TestHANASpatialFunctions", jiraKey = "HHH-12426")
|
||||
public class TestSpatialRestrictions extends SpatialFunctionalTestCase {
|
||||
|
||||
private static HSMessageLogger LOG = Logger.getMessageLogger(
|
||||
|
|
|
@ -794,14 +794,22 @@ public abstract class AbstractExpectationsFactory {
|
|||
expected.put( id, (T) results.getString( 2 ) );
|
||||
break;
|
||||
case INTEGER:
|
||||
expected.put( id, (T) Long.valueOf( results.getLong( 2 ) ) );
|
||||
break;
|
||||
case DOUBLE:
|
||||
Double value = Double.valueOf( results.getDouble( 2 ) );
|
||||
if ( results.wasNull() ) {
|
||||
value = null; //this is required because SQL Server converts automatically null to 0.0
|
||||
{
|
||||
Long value = Long.valueOf( results.getLong( 2 ) );
|
||||
if ( results.wasNull() ) {
|
||||
value = null; // This is required because the Hibernate BasicExtractor also checks ResultSet#wasNull which can lead to a mismatch between the expected and the actual results
|
||||
}
|
||||
expected.put( id, (T) value );
|
||||
}
|
||||
break;
|
||||
case DOUBLE:
|
||||
{
|
||||
Double value = Double.valueOf( results.getDouble( 2 ) );
|
||||
if ( results.wasNull() ) {
|
||||
value = null; //this is required because SQL Server converts automatically null to 0.0
|
||||
}
|
||||
expected.put( id, (T) value );
|
||||
}
|
||||
expected.put( id, (T) value );
|
||||
break;
|
||||
case BOOLEAN:
|
||||
expected.put( id, (T) Boolean.valueOf( results.getBoolean( 2 ) ) );
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue