HHH-14925 Remove deprecated BasicType implementations
This commit is contained in:
parent
f4909b7046
commit
0300e54fef
|
@ -202,10 +202,7 @@ create transform for db2gse.st_geometry db2_program (
|
|||
|
||||
Hibernate Spatial comes with the following types:
|
||||
|
||||
jts_geometry::
|
||||
Handled by `org.hibernate.spatial.JTSGeometryType`, it maps a database geometry column type to a `org.locationtech.jts.geom.Geometry` entity property type.
|
||||
geolatte_geometry::
|
||||
Handled by `org.hibernate.spatial.GeolatteGeometryType`, it maps a database geometry column type to an `org.geolatte.geom.Geometry` entity property type.
|
||||
TODO
|
||||
|
||||
It suffices to declare a property as either a JTS or a Geolatte-geom `Geometry` and Hibernate Spatial will map it using the
|
||||
relevant type.
|
||||
|
|
|
@ -14,6 +14,13 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
|
|||
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptorIndicators;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.GeometryCollection;
|
||||
import org.geolatte.geom.LineString;
|
||||
import org.geolatte.geom.MultiLineString;
|
||||
import org.geolatte.geom.MultiPoint;
|
||||
import org.geolatte.geom.MultiPolygon;
|
||||
import org.geolatte.geom.Point;
|
||||
import org.geolatte.geom.Polygon;
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
|
@ -29,17 +36,33 @@ public class GeolatteGeometryJavaTypeDescriptor extends AbstractJavaTypeDescript
|
|||
/**
|
||||
* an instance of this descriptor
|
||||
*/
|
||||
public static final GeolatteGeometryJavaTypeDescriptor INSTANCE = new GeolatteGeometryJavaTypeDescriptor();
|
||||
public static final GeolatteGeometryJavaTypeDescriptor GEOMETRY_INSTANCE = new GeolatteGeometryJavaTypeDescriptor(
|
||||
Geometry.class );
|
||||
public static final GeolatteGeometryJavaTypeDescriptor POINT_INSTANCE = new GeolatteGeometryJavaTypeDescriptor(
|
||||
Point.class );
|
||||
public static final GeolatteGeometryJavaTypeDescriptor LINESTRING_INSTANCE = new GeolatteGeometryJavaTypeDescriptor(
|
||||
LineString.class );
|
||||
public static final GeolatteGeometryJavaTypeDescriptor POLYGON_INSTANCE = new GeolatteGeometryJavaTypeDescriptor(
|
||||
Polygon.class );
|
||||
public static final GeolatteGeometryJavaTypeDescriptor GEOMETRYCOLL_INSTANCE = new GeolatteGeometryJavaTypeDescriptor(
|
||||
GeometryCollection.class );
|
||||
public static final GeolatteGeometryJavaTypeDescriptor MULTIPOINT_INSTANCE = new GeolatteGeometryJavaTypeDescriptor(
|
||||
MultiPoint.class );
|
||||
public static final GeolatteGeometryJavaTypeDescriptor MULTILINESTRING_INSTANCE = new GeolatteGeometryJavaTypeDescriptor(
|
||||
MultiLineString.class );
|
||||
public static final GeolatteGeometryJavaTypeDescriptor MULTIPOLYGON_INSTANCE = new GeolatteGeometryJavaTypeDescriptor(
|
||||
MultiPolygon.class );
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a type descriptor for the geolatte-geom {@code Geometry} type.
|
||||
*/
|
||||
public GeolatteGeometryJavaTypeDescriptor() {
|
||||
this( Wkt.Dialect.SFA_1_1_0 );
|
||||
public GeolatteGeometryJavaTypeDescriptor(Class<? extends Geometry> type) {
|
||||
this( type, Wkt.Dialect.SFA_1_1_0 );
|
||||
}
|
||||
|
||||
public GeolatteGeometryJavaTypeDescriptor(Wkt.Dialect wktDialect) {
|
||||
super( Geometry.class );
|
||||
public GeolatteGeometryJavaTypeDescriptor(Class<? extends Geometry> type, Wkt.Dialect wktDialect) {
|
||||
super( type );
|
||||
this.wktDialect = Wkt.Dialect.SFA_1_1_0;
|
||||
}
|
||||
|
||||
|
@ -49,7 +72,6 @@ public class GeolatteGeometryJavaTypeDescriptor extends AbstractJavaTypeDescript
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Geometry fromString(CharSequence string) {
|
||||
return Wkt.fromWkt( string.toString(), wktDialect );
|
||||
|
|
|
@ -1,60 +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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial;
|
||||
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.GeometryCollection;
|
||||
import org.geolatte.geom.LineString;
|
||||
import org.geolatte.geom.MultiLineString;
|
||||
import org.geolatte.geom.MultiPoint;
|
||||
import org.geolatte.geom.MultiPolygon;
|
||||
import org.geolatte.geom.Point;
|
||||
import org.geolatte.geom.Polygon;
|
||||
|
||||
/**
|
||||
* a {@code Type} that maps between the database geometry type and geolatte-geom {@code Geometry}.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 10/12/12
|
||||
*/
|
||||
public class GeolatteGeometryType extends AbstractSingleColumnStandardBasicType<Geometry> implements Spatial {
|
||||
|
||||
public static final String[] REG_KEYS = {
|
||||
Geometry.class.getCanonicalName(),
|
||||
Point.class.getCanonicalName(),
|
||||
Polygon.class.getCanonicalName(),
|
||||
MultiPolygon.class.getCanonicalName(),
|
||||
LineString.class.getCanonicalName(),
|
||||
MultiLineString.class.getCanonicalName(),
|
||||
MultiPoint.class.getCanonicalName(),
|
||||
GeometryCollection.class.getCanonicalName(),
|
||||
"geolatte_geometry"
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs an instance with the specified {@code SqlTypeDescriptor}
|
||||
*
|
||||
* @param sqlTypeDescriptor The Descriptor for the type used by the database for geometries.
|
||||
*/
|
||||
public GeolatteGeometryType(JdbcType sqlTypeDescriptor) {
|
||||
super( sqlTypeDescriptor, GeolatteGeometryJavaTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRegistrationKeys() {
|
||||
return REG_KEYS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "geolatte_geometry";
|
||||
}
|
||||
}
|
|
@ -12,15 +12,21 @@ import java.util.Locale;
|
|||
import org.hibernate.type.SqlTypes;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.java.AbstractJavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptorIndicators;
|
||||
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
import org.geolatte.geom.jts.JTSUtils;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.locationtech.jts.geom.GeometryCollection;
|
||||
import org.locationtech.jts.geom.LineString;
|
||||
import org.locationtech.jts.geom.MultiLineString;
|
||||
import org.locationtech.jts.geom.MultiPoint;
|
||||
import org.locationtech.jts.geom.MultiPolygon;
|
||||
import org.locationtech.jts.geom.Point;
|
||||
import org.locationtech.jts.geom.Polygon;
|
||||
import org.locationtech.jts.io.ParseException;
|
||||
import org.locationtech.jts.io.WKTReader;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
/**
|
||||
* Descriptor for JTS {@code Geometry}s.
|
||||
|
@ -33,13 +39,28 @@ public class JTSGeometryJavaTypeDescriptor extends AbstractJavaTypeDescriptor<Ge
|
|||
/**
|
||||
* An instance of this descriptor
|
||||
*/
|
||||
public static final JavaType<Geometry> INSTANCE = new JTSGeometryJavaTypeDescriptor();
|
||||
public static final JTSGeometryJavaTypeDescriptor GEOMETRY_INSTANCE = new JTSGeometryJavaTypeDescriptor(
|
||||
Geometry.class );
|
||||
public static final JTSGeometryJavaTypeDescriptor POINT_INSTANCE = new JTSGeometryJavaTypeDescriptor(
|
||||
Point.class );
|
||||
public static final JTSGeometryJavaTypeDescriptor LINESTRING_INSTANCE = new JTSGeometryJavaTypeDescriptor(
|
||||
LineString.class );
|
||||
public static final JTSGeometryJavaTypeDescriptor POLYGON_INSTANCE = new JTSGeometryJavaTypeDescriptor(
|
||||
Polygon.class );
|
||||
public static final JTSGeometryJavaTypeDescriptor GEOMETRYCOLL_INSTANCE = new JTSGeometryJavaTypeDescriptor(
|
||||
GeometryCollection.class );
|
||||
public static final JTSGeometryJavaTypeDescriptor MULTIPOINT_INSTANCE = new JTSGeometryJavaTypeDescriptor(
|
||||
MultiPoint.class );
|
||||
public static final JTSGeometryJavaTypeDescriptor MULTILINESTRING_INSTANCE = new JTSGeometryJavaTypeDescriptor(
|
||||
MultiLineString.class );
|
||||
public static final JTSGeometryJavaTypeDescriptor MULTIPOLYGON_INSTANCE = new JTSGeometryJavaTypeDescriptor(
|
||||
MultiPolygon.class );
|
||||
|
||||
/**
|
||||
* Initialize a type descriptor for the geolatte-geom {@code Geometry} type.
|
||||
*/
|
||||
public JTSGeometryJavaTypeDescriptor() {
|
||||
super( Geometry.class );
|
||||
public JTSGeometryJavaTypeDescriptor(Class<? extends Geometry> type) {
|
||||
super( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,6 +89,7 @@ public class JTSGeometryJavaTypeDescriptor extends AbstractJavaTypeDescriptor<Ge
|
|||
return JTSUtils.equalsExact3D( one, another );
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <X> X unwrap(Geometry value, Class<X> type, WrapperOptions options) {
|
||||
if ( value == null ) {
|
||||
|
@ -90,13 +112,13 @@ public class JTSGeometryJavaTypeDescriptor extends AbstractJavaTypeDescriptor<Ge
|
|||
if ( value == null ) {
|
||||
return null;
|
||||
}
|
||||
if ( Geometry.class.isInstance( value ) ) {
|
||||
if ( value instanceof Geometry ) {
|
||||
return (Geometry) value;
|
||||
}
|
||||
if ( org.geolatte.geom.Geometry.class.isInstance( value ) ) {
|
||||
return JTS.to( (org.geolatte.geom.Geometry) value );
|
||||
if ( value instanceof org.geolatte.geom.Geometry ) {
|
||||
return JTS.to( (org.geolatte.geom.Geometry<?>) value );
|
||||
}
|
||||
if ( CharSequence.class.isInstance( value ) ) {
|
||||
if ( value instanceof CharSequence ) {
|
||||
return fromString( (CharSequence) value );
|
||||
}
|
||||
throw unknownWrap( value.getClass() );
|
||||
|
|
|
@ -1,52 +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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.spatial;
|
||||
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* A {@code Type} that maps between the database geometry type and JTS {@code Geometry}.
|
||||
*
|
||||
* @author Karel Maesen
|
||||
*/
|
||||
public class JTSGeometryType extends AbstractSingleColumnStandardBasicType<Geometry> implements Spatial {
|
||||
|
||||
/**
|
||||
* Constructs an instance with the specified {@code SqlTypeDescriptor}
|
||||
*
|
||||
* @param jdbcType The descriptor for the type used by the database for geometries.
|
||||
*/
|
||||
public JTSGeometryType(JdbcType jdbcType) {
|
||||
super( jdbcType, JTSGeometryJavaTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRegistrationKeys() {
|
||||
return new String[] {
|
||||
Geometry.class.getCanonicalName(),
|
||||
org.locationtech.jts.geom.Point.class.getCanonicalName(),
|
||||
org.locationtech.jts.geom.Polygon.class.getCanonicalName(),
|
||||
org.locationtech.jts.geom.MultiPolygon.class.getCanonicalName(),
|
||||
org.locationtech.jts.geom.LineString.class.getCanonicalName(),
|
||||
org.locationtech.jts.geom.MultiLineString.class.getCanonicalName(),
|
||||
org.locationtech.jts.geom.MultiPoint.class.getCanonicalName(),
|
||||
org.locationtech.jts.geom.GeometryCollection.class.getCanonicalName(),
|
||||
"jts_geometry"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "jts_geometry";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -12,7 +12,7 @@ import java.io.Serializable;
|
|||
* Describes the features of a spatially enabled dialect.
|
||||
*
|
||||
* @author Karel Maesen
|
||||
* @deprecated To be removed in 6
|
||||
* @deprecated SpatialDialects are no longer needed since Hibernate 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SpatialDialect extends Serializable {
|
||||
|
|
|
@ -11,13 +11,37 @@ import org.hibernate.boot.model.FunctionContributions;
|
|||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.JTSGeometryJavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* Internal contract for Type and Function Contributors
|
||||
*/
|
||||
public interface ContributorImplementor {
|
||||
|
||||
void contributeTypes(TypeContributions typeContributions);
|
||||
default void contributeJavaTypes(TypeContributions typeContributions) {
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.GEOMETRY_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.POINT_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.LINESTRING_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.POLYGON_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.MULTIPOINT_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.MULTILINESTRING_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.MULTIPOLYGON_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.GEOMETRYCOLL_INSTANCE );
|
||||
|
||||
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.GEOMETRY_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.POINT_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.LINESTRING_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.POLYGON_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.MULTIPOINT_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.MULTILINESTRING_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.MULTIPOLYGON_INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.GEOMETRYCOLL_INSTANCE );
|
||||
|
||||
}
|
||||
|
||||
void contributeJdbcTypes(TypeContributions typeContributions);
|
||||
|
||||
void contributeFunctions(FunctionContributions functionContributions);
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ public class SpatialTypeContributor implements TypeContributor {
|
|||
ContributorImplementor contributorImplementor = ContributorResolver.resolveSpatialtypeContributorImplementor( serviceRegistry );
|
||||
|
||||
if (contributorImplementor != null) {
|
||||
contributorImplementor.contributeTypes( typeContributions );
|
||||
contributorImplementor.contributeJavaTypes( typeContributions );
|
||||
contributorImplementor.contributeJdbcTypes( typeContributions );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,9 +12,7 @@ import org.hibernate.boot.model.TypeContributions;
|
|||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.FunctionKey;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.contributor.ContributorImplementor;
|
||||
import org.hibernate.spatial.dialect.postgis.PGGeometryJdbcType;
|
||||
import org.hibernate.spatial.dialect.postgis.PostgisSqmFunctionDescriptors;
|
||||
|
@ -28,10 +26,9 @@ public class CockroachDbContributor implements ContributorImplementor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void contributeTypes(TypeContributions typeContributions) {
|
||||
public void contributeJdbcTypes(TypeContributions typeContributions) {
|
||||
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
|
||||
typeContributions.contributeType( new GeolatteGeometryType( PGGeometryJdbcType.INSTANCE_WKB_2 ) );
|
||||
typeContributions.contributeType( new JTSGeometryType( PGGeometryJdbcType.INSTANCE_WKB_2 ) );
|
||||
typeContributions.contributeJdbcTypeDescriptor( PGGeometryJdbcType.INSTANCE_WKB_2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,12 +11,9 @@ import org.hibernate.boot.model.FunctionContributions;
|
|||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.KeyedSqmFunctionDescriptors;
|
||||
import org.hibernate.spatial.contributor.ContributorImplementor;
|
||||
import org.hibernate.spatial.dialect.postgis.PostgisSqmFunctionDescriptors;
|
||||
|
||||
public class H2GisDialectContributor implements ContributorImplementor {
|
||||
|
||||
|
@ -26,10 +23,9 @@ public class H2GisDialectContributor implements ContributorImplementor {
|
|||
this.serviceRegistryegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
public void contributeTypes(TypeContributions typeContributions) {
|
||||
public void contributeJdbcTypes(TypeContributions typeContributions) {
|
||||
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
|
||||
typeContributions.contributeType( new GeolatteGeometryType( H2GISGeometryType.INSTANCE ) );
|
||||
typeContributions.contributeType( new JTSGeometryType( H2GISGeometryType.INSTANCE ) );
|
||||
typeContributions.contributeJdbcTypeDescriptor( H2GISGeometryType.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,9 +11,7 @@ import org.hibernate.boot.model.FunctionContributions;
|
|||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.KeyedSqmFunctionDescriptors;
|
||||
import org.hibernate.spatial.contributor.ContributorImplementor;
|
||||
import org.hibernate.spatial.dialect.mysql.MySQLGeometryJdbcType;
|
||||
|
@ -26,10 +24,9 @@ public class MariaDBDialectContributor implements ContributorImplementor {
|
|||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
public void contributeTypes(TypeContributions typeContributions) {
|
||||
public void contributeJdbcTypes(TypeContributions typeContributions) {
|
||||
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
|
||||
typeContributions.contributeType( new GeolatteGeometryType( MySQLGeometryJdbcType.INSTANCE ) );
|
||||
typeContributions.contributeType( new JTSGeometryType( MySQLGeometryJdbcType.INSTANCE ) );
|
||||
typeContributions.contributeJdbcTypeDescriptor( MySQLGeometryJdbcType.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,9 +11,7 @@ import org.hibernate.boot.model.FunctionContributions;
|
|||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.KeyedSqmFunctionDescriptors;
|
||||
import org.hibernate.spatial.contributor.ContributorImplementor;
|
||||
|
||||
|
@ -26,10 +24,9 @@ public class MySQLDialectContributor implements ContributorImplementor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void contributeTypes(TypeContributions typeContributions) {
|
||||
public void contributeJdbcTypes(TypeContributions typeContributions) {
|
||||
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
|
||||
typeContributions.contributeType( new GeolatteGeometryType( MySQLGeometryJdbcType.INSTANCE ) );
|
||||
typeContributions.contributeType( new JTSGeometryType( MySQLGeometryJdbcType.INSTANCE ) );
|
||||
typeContributions.contributeJdbcTypeDescriptor( MySQLGeometryJdbcType.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,12 +13,8 @@ import org.hibernate.boot.model.TypeContributions;
|
|||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.HibernateSpatialConfigurationSettings;
|
||||
import org.hibernate.spatial.JTSGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
import org.hibernate.spatial.SpatialRelation;
|
||||
|
@ -27,7 +23,6 @@ import org.hibernate.spatial.dialect.WithCustomJPAFilter;
|
|||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.codec.db.oracle.ConnectionFinder;
|
||||
import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory;
|
||||
|
||||
|
@ -56,11 +51,7 @@ class OracleSDOSupport implements SpatialDialect, Serializable, WithCustomJPAFil
|
|||
|
||||
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||
final SDOGeometryType sdoGeometryTypeDescriptor = mkSdoGeometryTypeDescriptor( serviceRegistry );
|
||||
typeContributions.contributeType( new GeolatteGeometryType( sdoGeometryTypeDescriptor ) );
|
||||
typeContributions.contributeType( new JTSGeometryType( sdoGeometryTypeDescriptor ) );
|
||||
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
private SDOGeometryType mkSdoGeometryTypeDescriptor(ServiceRegistry serviceRegistry) {
|
||||
|
|
|
@ -11,11 +11,7 @@ import org.hibernate.boot.model.FunctionContributions;
|
|||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.JTSGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.contributor.ContributorImplementor;
|
||||
|
||||
public class PostgisDialectContributor implements ContributorImplementor {
|
||||
|
@ -26,12 +22,9 @@ public class PostgisDialectContributor implements ContributorImplementor {
|
|||
this.serviceRegistryegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
public void contributeTypes(TypeContributions typeContributions) {
|
||||
@Override
|
||||
public void contributeJdbcTypes(TypeContributions typeContributions) {
|
||||
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
|
||||
// typeContributions.contributeType( new GeolatteGeometryType( PGGeometryJdbcType.INSTANCE_WKB_2 ) );
|
||||
// typeContributions.contributeType( new JTSGeometryType( PGGeometryJdbcType.INSTANCE_WKB_2 ) );
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.INSTANCE );
|
||||
typeContributions.contributeJdbcTypeDescriptor( PGGeometryJdbcType.INSTANCE_WKB_2 );
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,6 @@ import java.util.Map;
|
|||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.JTSGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
import org.hibernate.spatial.SpatialRelation;
|
||||
|
@ -32,11 +28,6 @@ class SqlServerSupport implements SpatialDialect, Serializable {
|
|||
}
|
||||
|
||||
void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||
typeContributions.contributeType( new GeolatteGeometryType( SqlServer2008GeometryType.INSTANCE ) );
|
||||
typeContributions.contributeType( new JTSGeometryType( SqlServer2008GeometryType.INSTANCE ) );
|
||||
|
||||
typeContributions.contributeJavaTypeDescriptor( GeolatteGeometryJavaTypeDescriptor.INSTANCE );
|
||||
typeContributions.contributeJavaTypeDescriptor( JTSGeometryJavaTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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.mapping;
|
||||
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.spatial.GeolatteGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import org.geolatte.geom.C2D;
|
||||
import org.geolatte.geom.MultiLineString;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
|
||||
@DomainModel(annotatedClasses = { MLEntity.class })
|
||||
@ServiceRegistry
|
||||
@SessionFactory
|
||||
public class GeometryMappingTest {
|
||||
|
||||
@Test
|
||||
public void testSimpleEntity(SessionFactoryScope scope) {
|
||||
final EntityPersister entityDescriptor = scope.getSessionFactory()
|
||||
.getDomainModel()
|
||||
.getEntityDescriptor( MLEntity.class );
|
||||
final JdbcTypeRegistry jdbcTypeRegistry = entityDescriptor.getFactory()
|
||||
.getTypeConfiguration()
|
||||
.getJdbcTypeDescriptorRegistry();
|
||||
|
||||
final JavaTypeRegistry javaTypeRegistry = entityDescriptor.getFactory()
|
||||
.getTypeConfiguration()
|
||||
.getJavaTypeDescriptorRegistry();
|
||||
|
||||
ModelPart part = entityDescriptor.findSubPart( "lineString" );
|
||||
assertThat( part.getJavaTypeDescriptor(), equalTo( GeolatteGeometryJavaTypeDescriptor.MULTILINESTRING_INSTANCE ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Entity
|
||||
class MLEntity {
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
private String type;
|
||||
private MultiLineString<C2D> lineString;
|
||||
|
||||
public MLEntity(Integer id, String type, MultiLineString<C2D> lineString) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.lineString = lineString;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public MultiLineString<C2D> getLineString() {
|
||||
return lineString;
|
||||
}
|
||||
|
||||
public void setLineString(MultiLineString<C2D> lineString) {
|
||||
this.lineString = lineString;
|
||||
}
|
||||
}
|
|
@ -52,7 +52,7 @@ public class GeometryConverterTest extends BaseUnitTestCase {
|
|||
|
||||
assertThat(
|
||||
typeConfiguration.getJavaTypeDescriptorRegistry().getDescriptor( Geometry.class ),
|
||||
sameInstance( GeolatteGeometryJavaTypeDescriptor.INSTANCE )
|
||||
sameInstance( GeolatteGeometryJavaTypeDescriptor.GEOMETRY_INSTANCE )
|
||||
);
|
||||
|
||||
// todo (5.3) : what to assert wrt to SqlTypeDescriptor? Anything?
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.locationtech.jts.geom.Point;
|
|||
public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory {
|
||||
|
||||
private final SDOGeometryValueExtractor decoder = new SDOGeometryValueExtractor(
|
||||
JTSGeometryJavaTypeDescriptor.INSTANCE,
|
||||
JTSGeometryJavaTypeDescriptor.GEOMETRY_INSTANCE,
|
||||
null
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue