From cbf98a18454db816044c1c397661eb46b3506cb7 Mon Sep 17 00:00:00 2001 From: Karel Maesen Date: Fri, 21 Jan 2022 14:46:26 +0100 Subject: [PATCH] HHH-14807 Upgrade SpatialPredicates for Oracle --- .../hibernate/spatial/SpatialAggregate.java | 28 -------- .../hibernate/spatial/SpatialAnalysis.java | 53 --------------- .../dialect/SpatialFunctionsRegistry.java | 37 ---------- .../spatial/dialect/WithCustomJPAFilter.java | 18 ----- .../oracle/OracleDialectContributor.java | 25 +++---- .../oracle/OracleSpatialAggregate.java | 41 ----------- .../oracle/OracleSpatialSQLMMFunction.java | 2 +- .../dialect/oracle/SDOGeometryType.java | 10 +-- .../dialect/oracle/SDOLIteralFormatter.java | 38 +++++++++++ .../dialect/oracle/SpatialAggregateImpl.java | 68 ------------------- .../dialect/sqlserver/SqlServerFunctions.java | 6 +- .../dialect/sqlserver/SqlServerSupport.java | 10 +-- .../SpatialPredicatesTestBindingMode.java | 4 +- .../SpatialPredicatesTestInlineMode.java | 4 +- .../testing/dialects/PredicateRegexes.java | 6 +- .../oracle/OraclePredicateRegexes.java | 51 ++++++++++++++ .../dialects/oracle/OracleSDOTestSupport.java | 2 +- 17 files changed, 127 insertions(+), 276 deletions(-) delete mode 100644 hibernate-spatial/src/main/java/org/hibernate/spatial/SpatialAggregate.java delete mode 100644 hibernate-spatial/src/main/java/org/hibernate/spatial/SpatialAnalysis.java delete mode 100644 hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/SpatialFunctionsRegistry.java delete mode 100644 hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/WithCustomJPAFilter.java delete mode 100644 hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialAggregate.java create mode 100644 hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOLIteralFormatter.java delete mode 100644 hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SpatialAggregateImpl.java create mode 100644 hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/oracle/OraclePredicateRegexes.java diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/SpatialAggregate.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/SpatialAggregate.java deleted file mode 100644 index 2ca2957f3b..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/SpatialAggregate.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 . - */ -package org.hibernate.spatial; - -/** - * Enumeration of types of Spatial Aggregation - * - * @author Karel Maesen - * @deprecated Will be removed in 6.0 - */ -@Deprecated -public interface SpatialAggregate { - - /** - * Enum value for extent aggregation. - */ - public static final int EXTENT = 1; - - /** - * Enum value for union aggregate (only supported in DB2) - */ - public static final int UNION = 2; - -} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/SpatialAnalysis.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/SpatialAnalysis.java deleted file mode 100644 index ab71441a71..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/SpatialAnalysis.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 . - */ -package org.hibernate.spatial; - -/** - * The spatial analysis functions defined in the OGC SFS specification. - * - * @author Karel Maesen - * @deprecated Will be removed in 6 - */ -@Deprecated -public interface SpatialAnalysis { - - /** - * The distance function - */ - public static int DISTANCE = 1; - - /** - * The buffer function - */ - public static int BUFFER = 2; - - /** - * The convexhull function - */ - public static int CONVEXHULL = 3; - - /** - * The intersection function - */ - public static int INTERSECTION = 4; - - /** - * The union function - */ - public static int UNION = 5; - - /** - * The difference function - */ - public static int DIFFERENCE = 6; - - /** - * The symmetric difference function - */ - public static int SYMDIFFERENCE = 7; - -} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/SpatialFunctionsRegistry.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/SpatialFunctionsRegistry.java deleted file mode 100644 index 8c22f8226f..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/SpatialFunctionsRegistry.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 . - */ -package org.hibernate.spatial.dialect; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.hibernate.query.sqm.function.SqmFunctionDescriptor; - -/** - * Registers all available spatial functions for a Dialect - *

- * Created by Karel Maesen, Geovise BVBA on 29/10/16. - * @Deprecated Use KeyedSqmFunctionDescriptors - */ -public abstract class SpatialFunctionsRegistry implements Iterable>, Serializable { - protected final Map functionMap = new HashMap(); - - public void put(String name, SqmFunctionDescriptor function) { - this.functionMap.put( name, function ); - } - - @Override - public Iterator> iterator() { - return functionMap.entrySet().iterator(); - } - - public SqmFunctionDescriptor get(String functionName) { - return functionMap.get( functionName ); - } -} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/WithCustomJPAFilter.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/WithCustomJPAFilter.java deleted file mode 100644 index 2d81d15d23..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/WithCustomJPAFilter.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 . - */ -package org.hibernate.spatial.dialect; - -/** - * An Interface for {@code SpatialDialect}s that require a custom - * rendering to JPAQL for the filter predicate - *

- * Created by Karel Maesen, Geovise BVBA on 09/02/2020. - */ -public interface WithCustomJPAFilter { - - String filterExpression(String geometryParam, String filterParam); -} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleDialectContributor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleDialectContributor.java index f9ef6681f0..b37db20c2d 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleDialectContributor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleDialectContributor.java @@ -25,9 +25,16 @@ import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory; public class OracleDialectContributor implements ContributorImplementor { private final ServiceRegistry serviceRegistry; + private final boolean useSTGeometry; public OracleDialectContributor(ServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; + final var cfgService = getServiceRegistry().getService( ConfigurationService.class ); + this.useSTGeometry = cfgService.getSetting( + HibernateSpatialConfigurationSettings.ORACLE_OGC_STRICT, + StandardConverters.BOOLEAN, + false + ); } @Override @@ -36,6 +43,7 @@ public class OracleDialectContributor implements ContributorImplementor { final ConfigurationService cfgService = getServiceRegistry().getService( ConfigurationService.class ); final StrategySelector strategySelector = getServiceRegistry().getService( StrategySelector.class ); + final ConnectionFinder connectionFinder = strategySelector.resolveStrategy( ConnectionFinder.class, cfgService.getSetting( @@ -48,27 +56,20 @@ public class OracleDialectContributor implements ContributorImplementor { HSMessageLogger.LOGGER.connectionFinder( connectionFinder.getClass().getCanonicalName() ); SDOGeometryType sdoGeometryType = new SDOGeometryType( - new OracleJDBCTypeFactory( - connectionFinder - ) + new OracleJDBCTypeFactory( connectionFinder ), useSTGeometry ); - typeContributions.contributeJdbcTypeDescriptor( sdoGeometryType ); + typeContributions.contributeJdbcType( sdoGeometryType ); } @Override public void contributeFunctions(FunctionContributions functionContributions) { HSMessageLogger.LOGGER.functionContributions( this.getClass().getCanonicalName() ); - final var cfgService = getServiceRegistry().getService( ConfigurationService.class ); - boolean isOgcStrict = cfgService.getSetting( - HibernateSpatialConfigurationSettings.ORACLE_OGC_STRICT, - StandardConverters.BOOLEAN, - false - ); KeyedSqmFunctionDescriptors functionDescriptors; - if (isOgcStrict) - functionDescriptors = new OracleSQLMMFunctionDescriptors( functionContributions); + if ( useSTGeometry ) { + functionDescriptors = new OracleSQLMMFunctionDescriptors( functionContributions ); + } else { functionDescriptors = new OracleSDOFunctionDescriptors( functionContributions ); } diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialAggregate.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialAggregate.java deleted file mode 100644 index bb733de83e..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialAggregate.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 . - */ - -package org.hibernate.spatial.dialect.oracle; - -/** - * Defines types of Oracle Spatial aggregate functions - * - * @author Karel Maesen, Geovise BVBA - */ -public interface OracleSpatialAggregate extends org.hibernate.spatial.SpatialAggregate { - - /** - * LRS_CONCAT aggregate function - */ - public static int LRS_CONCAT = 100; - - /** - * CENTROID aggregate function - */ - public static int CENTROID = 101; - - /** - * CONCAT_LINES aggregate function - */ - public static int CONCAT_LINES = 102; - - /** - * UNION aggregate function - */ - public static int UNION = 103; - - /** - * CONVEXHULL aggregate function - */ - public static int CONVEXHULL = 104; -} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialSQLMMFunction.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialSQLMMFunction.java index 08e4e54c9a..5398e20f47 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialSQLMMFunction.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialSQLMMFunction.java @@ -68,7 +68,7 @@ public class OracleSpatialSQLMMFunction extends OracleSpatialFunction { for ( int i = 1; i < arguments.size(); i++ ) { Expression param = (Expression) arguments.get( i ); - if ( param.getExpressionType().getJdbcMappings().get( 0 ).getJdbcTypeDescriptor() + if ( param.getExpressionType().getJdbcMappings().get( 0 ).getJdbcType() .getDefaultSqlTypeCode() == SqlTypes.GEOMETRY ) { sqlAppender.appendSql( "ST_GEOMETRY(" ); walker.render( param, SqlAstNodeRenderingMode.DEFAULT); diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOGeometryType.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOGeometryType.java index 491aeff43b..7da7280b72 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOGeometryType.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOGeometryType.java @@ -9,7 +9,6 @@ package org.hibernate.spatial.dialect.oracle; import java.sql.Types; -import org.hibernate.spatial.GeometryLiteralFormatter; import org.hibernate.type.SqlTypes; import org.hibernate.type.descriptor.ValueBinder; import org.hibernate.type.descriptor.ValueExtractor; @@ -17,7 +16,6 @@ import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter; import org.hibernate.type.descriptor.jdbc.JdbcType; -import org.geolatte.geom.codec.Wkt; import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory; /** @@ -28,14 +26,17 @@ import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory; public class SDOGeometryType implements JdbcType { private final OracleJDBCTypeFactory typeFactory; + private final boolean useSTGeometry; /** * Constructs a {@code SqlTypeDescriptor} for the Oracle SDOGeometry type. * * @param typeFactory the type factory to use. + * @param useSTGeometry */ - public SDOGeometryType(OracleJDBCTypeFactory typeFactory) { + public SDOGeometryType(OracleJDBCTypeFactory typeFactory, boolean useSTGeometry) { this.typeFactory = typeFactory; + this.useSTGeometry = useSTGeometry; } @Override @@ -48,9 +49,10 @@ public class SDOGeometryType implements JdbcType { return SqlTypes.GEOMETRY; } + @Override public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaType javaTypeDescriptor) { - return new GeometryLiteralFormatter( javaTypeDescriptor, Wkt.Dialect.SFA_1_1_0, "ST_GeomFromText" ); + return new OracleJdbcLiteralFormatter<>( javaTypeDescriptor ); } @Override diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOLIteralFormatter.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOLIteralFormatter.java new file mode 100644 index 0000000000..0ffddb564d --- /dev/null +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOLIteralFormatter.java @@ -0,0 +1,38 @@ +/* + * 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 . + */ + +package org.hibernate.spatial.dialect.oracle; + +import org.hibernate.dialect.Dialect; +import org.hibernate.sql.ast.spi.SqlAppender; +import org.hibernate.type.descriptor.WrapperOptions; +import org.hibernate.type.descriptor.java.JavaType; +import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter; + +import org.geolatte.geom.Geometry; +import org.geolatte.geom.codec.Wkt; + +class OracleJdbcLiteralFormatter implements JdbcLiteralFormatter { + + private final JavaType javaType; + + OracleJdbcLiteralFormatter(JavaType javaType) { + this.javaType = javaType; + } + + @Override + public void appendJdbcLiteral( + SqlAppender appender, T value, Dialect dialect, WrapperOptions wrapperOptions) { + Geometry geom = javaType.unwrap( value, Geometry.class, wrapperOptions ); + appender.appendSql( "ST_GEOMETRY.FROM_WKT" ); + appender.appendSql( "('" ); + appender.appendSql( Wkt.toWkt( geom, Wkt.Dialect.SFA_1_2_1 ) ); + appender.appendSql( "'," ); + appender.appendSql( ( Math.max( geom.getSRID(), 0 ) ) ); + appender.appendSql( ").Geom" ); + } +} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SpatialAggregateImpl.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SpatialAggregateImpl.java deleted file mode 100644 index 6c568fa0d7..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SpatialAggregateImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 . - */ - -package org.hibernate.spatial.dialect.oracle; - -/** - * Provides Aggregate type spatial function interpretation - */ -class SpatialAggregateImpl { - - private static final String SDO_AGGR = "SDO_AGGR_"; - private boolean aggregateType; - private String aggregateSyntax; - - SpatialAggregateImpl() { - } - - SpatialAggregateImpl(int aggregation) { - - String specificAggrSyntax; - - switch ( aggregation ) { - case org.hibernate.spatial.SpatialAggregate.EXTENT: - specificAggrSyntax = "MBR"; - aggregateType = false; - break; - case OracleSpatialAggregate.LRS_CONCAT: - specificAggrSyntax = "LRS_CONCAT"; - aggregateType = true; - break; - case OracleSpatialAggregate.CENTROID: - specificAggrSyntax = "CENTROID"; - aggregateType = true; - break; - case OracleSpatialAggregate.CONCAT_LINES: - specificAggrSyntax = "CONCAT_LINES"; - aggregateType = false; - break; - case OracleSpatialAggregate.UNION: - specificAggrSyntax = "UNION"; - aggregateType = true; - break; - case OracleSpatialAggregate.CONVEXHULL: - specificAggrSyntax = "CONVEXHULL"; - aggregateType = true; - break; - default: - specificAggrSyntax = null; - break; - } - if ( specificAggrSyntax != null ) { - aggregateSyntax = SDO_AGGR + specificAggrSyntax; - } - } - - public boolean isAggregateType() { - return aggregateType; - } - - public String getAggregateSyntax() { - return aggregateSyntax; - } - -} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerFunctions.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerFunctions.java index 9eac5c744c..67a0b74a53 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerFunctions.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerFunctions.java @@ -7,14 +7,10 @@ package org.hibernate.spatial.dialect.sqlserver; -import org.hibernate.spatial.dialect.SpatialFunctionsRegistry; - - - /** * Created by Karel Maesen, Geovise BVBA on 19/09/2018. */ -class SqlServerFunctions extends SpatialFunctionsRegistry { +class SqlServerFunctions{ public SqlServerFunctions() { //TODO -- re-implement. In 6.0 there is no longer a SQLFunctionTemplate class diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerSupport.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerSupport.java index 968ed11085..7b9b6ace49 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerSupport.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerSupport.java @@ -22,10 +22,10 @@ import org.hibernate.spatial.SpatialRelation; class SqlServerSupport implements SpatialDialect, Serializable { private SqlServerFunctions functions = new SqlServerFunctions(); - - Iterable> functionsToRegister() { - return functions; - } +// +// Iterable> functionsToRegister() { +// return functions; +// } void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { } @@ -100,7 +100,7 @@ class SqlServerSupport implements SpatialDialect, Serializable { public boolean supports(SpatialFunction function) { - return ( functions.get( function.toString() ) != null ); + return true; } } diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/predicates/SpatialPredicatesTestBindingMode.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/predicates/SpatialPredicatesTestBindingMode.java index d123a731bf..3b3c86f502 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/predicates/SpatialPredicatesTestBindingMode.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/predicates/SpatialPredicatesTestBindingMode.java @@ -10,6 +10,7 @@ package org.hibernate.spatial.integration.predicates; import java.util.stream.Stream; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.spatial.HibernateSpatialConfigurationSettings; import org.hibernate.spatial.testing.IsSupportedBySpatial; import org.hibernate.spatial.testing.dialects.PredicateRegexes; @@ -20,7 +21,8 @@ import org.hibernate.testing.orm.junit.Setting; @RequiresDialectFeature(feature = IsSupportedBySpatial.class) @ServiceRegistry(settings = { - @Setting(name = AvailableSettings.CRITERIA_VALUE_HANDLING_MODE, value = "BIND") + @Setting(name = AvailableSettings.CRITERIA_VALUE_HANDLING_MODE, value = "BIND"), + @Setting(name = HibernateSpatialConfigurationSettings.ORACLE_OGC_STRICT, value = "true") }) @SessionFactory public class SpatialPredicatesTestBindingMode extends SpatialPredicatesTest { diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/predicates/SpatialPredicatesTestInlineMode.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/predicates/SpatialPredicatesTestInlineMode.java index cf10f2a575..c75462950c 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/predicates/SpatialPredicatesTestInlineMode.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/predicates/SpatialPredicatesTestInlineMode.java @@ -10,6 +10,7 @@ package org.hibernate.spatial.integration.predicates; import java.util.stream.Stream; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.spatial.HibernateSpatialConfigurationSettings; import org.hibernate.spatial.testing.IsSupportedBySpatial; import org.hibernate.spatial.testing.dialects.PredicateRegexes; @@ -20,7 +21,8 @@ import org.hibernate.testing.orm.junit.Setting; @RequiresDialectFeature(feature = IsSupportedBySpatial.class) @ServiceRegistry(settings = { - @Setting(name = AvailableSettings.CRITERIA_VALUE_HANDLING_MODE, value = "INLINE") + @Setting(name = AvailableSettings.CRITERIA_VALUE_HANDLING_MODE, value = "INLINE"), + @Setting(name = HibernateSpatialConfigurationSettings.ORACLE_OGC_STRICT, value = "true") }) @SessionFactory public class SpatialPredicatesTestInlineMode extends SpatialPredicatesTest{ diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/PredicateRegexes.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/PredicateRegexes.java index 8e9b7df0e9..9eed821651 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/PredicateRegexes.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/PredicateRegexes.java @@ -80,10 +80,14 @@ public class PredicateRegexes { .map( mkPredRegex ); } - private void add(String predicate, String inlineRegex, String bindingRegex) { + protected void add(String predicate, String inlineRegex, String bindingRegex) { regexes.put( predicate, new RegexPair( inlineRegex, bindingRegex ) ); } + protected void add(String predicate, String regex) { + regexes.put( predicate, new RegexPair( regex, regex ) ); + } + static public class PredicateRegex { public final String predicate; public final String regex; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/oracle/OraclePredicateRegexes.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/oracle/OraclePredicateRegexes.java new file mode 100644 index 0000000000..d9edc894ad --- /dev/null +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/oracle/OraclePredicateRegexes.java @@ -0,0 +1,51 @@ +/* + * 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 . + */ + +package org.hibernate.spatial.testing.dialects.oracle; + +import org.hibernate.spatial.testing.dialects.PredicateRegexes; + +public class OraclePredicateRegexes extends PredicateRegexes { + + public OraclePredicateRegexes() { + super( null ); + add( + "overlaps", + "select .* from .* where st_geometry\\(.*\\).st_overlap.*=.*" + ); + add( + "crosses", + "select .* from .* where st_geometry\\(.*\\).st_crosses.*=.*" + + ); + add( + "contains", + "select .* from .* where st_geometry\\(.*\\).st_contains.*=.*" + ); + add( + "disjoint", + "select .* from .* where st_geometry\\(.*\\).st_disjoint.*=.*" + ); + add( + "touches", + "select .* from .* where st_geometry\\(.*\\).st_touches.*=.*" + ); + add( + "within", + "select .* from .* where st_geometry\\(.*\\).st_within.*=.*" + + ); + add( + "intersects", + "select .* from .* where st_geometry\\(.*\\).st_intersects.*=.*" + ); + add( + "eq", + "select .* from .* where st_geometry\\(.*\\).st_equals.*=.*" + ); + } +} diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/oracle/OracleSDOTestSupport.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/oracle/OracleSDOTestSupport.java index c21b6a69d8..b4862f6497 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/oracle/OracleSDOTestSupport.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/oracle/OracleSDOTestSupport.java @@ -33,7 +33,7 @@ public class OracleSDOTestSupport extends TestSupport { @Override public PredicateRegexes predicateRegexes() { - return new PredicateRegexes( "st_" ); + return new OraclePredicateRegexes(); } @Override