1212import org .hibernate .dialect .PostgreSQL95Dialect ;
1313import org .hibernate .dialect .function .SQLFunction ;
1414import org .hibernate .service .ServiceRegistry ;
15- import org .hibernate .spatial .SpatialDialect ;
16- import org .hibernate .spatial .SpatialFunction ;
1715
1816/**
1917 * Extends the {@code PostgreSQL95Dialect} to add support for the Postgis spatial types, functions and operators .
2018 * Created by Karel Maesen, Geovise BVBA on 01/11/16.
2119 */
22- public class PostgisPG95Dialect extends PostgreSQL95Dialect implements SpatialDialect {
23-
24-
25- transient private PostgisSupport support = new PostgisSupport ();
20+ public class PostgisPG95Dialect extends PostgreSQL95Dialect implements PGSpatialDialectTrait {
2621
2722 /**
2823 * Creates an instance
@@ -33,7 +28,7 @@ public PostgisPG95Dialect() {
3328 PGGeometryTypeDescriptor .INSTANCE_WKB_1 .getSqlType (),
3429 "GEOMETRY"
3530 );
36- for ( Map .Entry <String , SQLFunction > entry : support . functionsToRegister () ) {
31+ for ( Map .Entry <String , SQLFunction > entry : functionsToRegister () ) {
3732 registerFunction ( entry .getKey (), entry .getValue () );
3833 }
3934 }
@@ -47,110 +42,4 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
4742 support .contributeTypes ( typeContributions , serviceRegistry );
4843 }
4944
50- /**
51- * Returns the SQL fragment for the SQL WHERE-clause when parsing
52- * <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s
53- * into prepared statements.
54- * <p/>
55- *
56- * @param columnName The name of the geometry-typed column to which the relation is
57- * applied
58- * @param spatialRelation The type of spatial relation (as defined in
59- * <code>SpatialRelation</code>).
60- *
61- * @return SQL fragment {@code SpatialRelateExpression}
62- */
63- @ Override
64- public String getSpatialRelateSQL (String columnName , int spatialRelation ) {
65- return support .getSpatialRelateSQL ( columnName , spatialRelation );
66- }
67-
68- /**
69- * Returns the SQL fragment for the SQL WHERE-expression when parsing
70- * <code>org.hibernate.spatial.criterion.SpatialFilterExpression</code>s
71- * into prepared statements.
72- *
73- * @param columnName The name of the geometry-typed column to which the filter is
74- * be applied
75- *
76- * @return Rhe SQL fragment for the {@code SpatialFilterExpression}
77- */
78- @ Override
79- public String getSpatialFilterExpression (String columnName ) {
80- return support .getSpatialFilterExpression ( columnName );
81- }
82-
83- /**
84- * Returns the SQL fragment for the specfied Spatial aggregate expression.
85- *
86- * @param columnName The name of the Geometry property
87- * @param aggregation The type of <code>SpatialAggregate</code>
88- *
89- * @return The SQL fragment for the projection
90- */
91- @ Override
92- public String getSpatialAggregateSQL (String columnName , int aggregation ) {
93- return support .getSpatialAggregateSQL ( columnName , aggregation );
94- }
95-
96- /**
97- * Returns The SQL fragment when parsing a <code>DWithinExpression</code>.
98- *
99- * @param columnName The geometry column to test against
100- *
101- * @return The SQL fragment when parsing a <code>DWithinExpression</code>.
102- */
103- @ Override
104- public String getDWithinSQL (String columnName ) {
105- return support .getDWithinSQL ( columnName );
106- }
107-
108- /**
109- * Returns the SQL fragment when parsing a <code>HavingSridExpression</code>.
110- *
111- * @param columnName The geometry column to test against
112- *
113- * @return The SQL fragment for a <code>HavingSridExpression</code>.
114- */
115- @ Override
116- public String getHavingSridSQL (String columnName ) {
117- return support .getHavingSridSQL ( columnName );
118- }
119-
120- /**
121- * Returns the SQL fragment when parsing a <code>IsEmptyExpression</code> or
122- * <code>IsNotEmpty</code> expression.
123- *
124- * @param columnName The geometry column
125- * @param isEmpty Whether the geometry is tested for empty or non-empty
126- *
127- * @return The SQL fragment for the isempty function
128- */
129- @ Override
130- public String getIsEmptySQL (String columnName , boolean isEmpty ) {
131- return support .getIsEmptySQL ( columnName , isEmpty );
132- }
133-
134- /**
135- * Returns true if this <code>SpatialDialect</code> supports a specific filtering function.
136- * <p> This is intended to signal DB-support for fast window queries, or MBR-overlap queries.</p>
137- *
138- * @return True if filtering is supported
139- */
140- @ Override
141- public boolean supportsFiltering () {
142- return support .supportsFiltering ();
143- }
144-
145- /**
146- * Does this dialect supports the specified <code>SpatialFunction</code>.
147- *
148- * @param function <code>SpatialFunction</code>
149- *
150- * @return True if this <code>SpatialDialect</code> supports the spatial function specified by the function parameter.
151- */
152- @ Override
153- public boolean supports (SpatialFunction function ) {
154- return support .supports ( function );
155- }
15645}
0 commit comments