HHH-10211 - Fix serialization of Postgis dialects

This commit is contained in:
Karel Maesen 2016-11-01 17:51:13 +01:00
parent d1f22d490c
commit c3b1a39944
12 changed files with 52 additions and 43 deletions

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate.spatial.dialect; package org.hibernate.spatial.dialect;
import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -18,15 +19,15 @@
* *
* Created by Karel Maesen, Geovise BVBA on 29/10/16. * Created by Karel Maesen, Geovise BVBA on 29/10/16.
*/ */
public abstract class SpatialFunctionsRegistry implements Iterable<Map.Entry<String, StandardSQLFunction>> { public abstract class SpatialFunctionsRegistry implements Iterable<Map.Entry<String, SQLFunction>>, Serializable {
protected final Map<String, StandardSQLFunction> functionMap = new HashMap<String, StandardSQLFunction>(); protected final Map<String, SQLFunction> functionMap = new HashMap<String, SQLFunction>();
public void put(String name, StandardSQLFunction function ) { public void put(String name, StandardSQLFunction function ) {
this.functionMap.put( name, function ); this.functionMap.put( name, function );
} }
@Override @Override
public Iterator<Map.Entry<String, StandardSQLFunction>> iterator() { public Iterator<Map.Entry<String, SQLFunction>> iterator() {
return functionMap.entrySet().iterator(); return functionMap.entrySet().iterator();
} }

View File

@ -16,6 +16,7 @@
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.MySQL5Dialect; import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
@ -48,7 +49,7 @@ public MySQL56SpatialDialect() {
"GEOMETRY" "GEOMETRY"
); );
final MySQLSpatialFunctions functionsToRegister = overrideObjectShapeFunctions( new MySQLSpatialFunctions() ); final MySQLSpatialFunctions functionsToRegister = overrideObjectShapeFunctions( new MySQLSpatialFunctions() );
for ( Map.Entry<String, StandardSQLFunction> entry : functionsToRegister ) { for ( Map.Entry<String, SQLFunction> entry : functionsToRegister ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -11,7 +11,7 @@
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.MySQL5InnoDBDialect; import org.hibernate.dialect.MySQL5InnoDBDialect;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
@ -36,7 +36,7 @@ public MySQL5InnoDBSpatialDialect() {
MySQLGeometryTypeDescriptor.INSTANCE.getSqlType(), MySQLGeometryTypeDescriptor.INSTANCE.getSqlType(),
"GEOMETRY" "GEOMETRY"
); );
for ( Map.Entry<String, StandardSQLFunction> entry : new MySQLSpatialFunctions() ) { for ( Map.Entry<String, SQLFunction> entry : new MySQLSpatialFunctions() ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -10,8 +10,7 @@
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.MySQLDialect; import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.GeolatteGeometryType; import org.hibernate.spatial.GeolatteGeometryType;
import org.hibernate.spatial.JTSGeometryType; import org.hibernate.spatial.JTSGeometryType;
@ -35,7 +34,7 @@ public MySQLSpatialDialect() {
MySQLGeometryTypeDescriptor.INSTANCE.getSqlType(), MySQLGeometryTypeDescriptor.INSTANCE.getSqlType(),
"GEOMETRY" "GEOMETRY"
); );
for ( Map.Entry<String, StandardSQLFunction> entry : new MySQLSpatialFunctions() ) { for ( Map.Entry<String, SQLFunction> entry : new MySQLSpatialFunctions() ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -10,20 +10,20 @@
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.PostgreSQL82Dialect; import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
/** /**
* Extends the {@code PostgreSQL82Dialect} to add support for the Postgis spatial types, functions and operators . * Extends the {@code PostgreSQL82Dialect} to add support for the Postgis spatial types, functions and operators .
* * <p>
* Created by Karel Maesen, Geovise BVBA on 01/11/16. * Created by Karel Maesen, Geovise BVBA on 01/11/16.
*/ */
public class PostgisPG82Dialect extends PostgreSQL82Dialect implements SpatialDialect { public class PostgisPG82Dialect extends PostgreSQL82Dialect implements SpatialDialect {
private PostgisSupport support = new PostgisSupport(); transient private PostgisSupport support = new PostgisSupport();
/** /**
* Creates an instance * Creates an instance
@ -34,7 +34,7 @@ public PostgisPG82Dialect() {
PGGeometryTypeDescriptor.INSTANCE.getSqlType(), PGGeometryTypeDescriptor.INSTANCE.getSqlType(),
"GEOMETRY" "GEOMETRY"
); );
for ( Map.Entry<String, StandardSQLFunction> entry : support.functionsToRegister() ) { for ( Map.Entry<String, SQLFunction> entry : support.functionsToRegister() ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -10,20 +10,21 @@
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.PostgreSQL91Dialect; import org.hibernate.dialect.PostgreSQL91Dialect;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
/** /**
* Extends the {@code PostgreSQL91Dialect} to add support for the Postgis spatial types, functions and operators . * Extends the {@code PostgreSQL91Dialect} to add support for the Postgis spatial types, functions and operators .
* * <p>
* Created by Karel Maesen, Geovise BVBA on 01/11/16. * Created by Karel Maesen, Geovise BVBA on 01/11/16.
*/ */
public class PostgisPG91Dialect extends PostgreSQL91Dialect implements SpatialDialect { public class PostgisPG91Dialect extends PostgreSQL91Dialect implements SpatialDialect {
private PostgisSupport support = new PostgisSupport(); transient private PostgisSupport support = new PostgisSupport();
/** /**
* Creates an instance * Creates an instance
*/ */
@ -33,7 +34,7 @@ public PostgisPG91Dialect() {
PGGeometryTypeDescriptor.INSTANCE.getSqlType(), PGGeometryTypeDescriptor.INSTANCE.getSqlType(),
"GEOMETRY" "GEOMETRY"
); );
for ( Map.Entry<String, StandardSQLFunction> entry : support.functionsToRegister() ) { for ( Map.Entry<String, SQLFunction> entry : support.functionsToRegister() ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -10,20 +10,21 @@
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.PostgreSQL92Dialect; import org.hibernate.dialect.PostgreSQL92Dialect;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
/** /**
* Extends the {@code PostgreSQL92Dialect} to add support for the Postgis spatial types, functions and operators . * Extends the {@code PostgreSQL92Dialect} to add support for the Postgis spatial types, functions and operators .
* * <p>
* Created by Karel Maesen, Geovise BVBA on 01/11/16. * Created by Karel Maesen, Geovise BVBA on 01/11/16.
*/ */
public class PostgisPG92Dialect extends PostgreSQL92Dialect implements SpatialDialect { public class PostgisPG92Dialect extends PostgreSQL92Dialect implements SpatialDialect {
private PostgisSupport support = new PostgisSupport(); transient private PostgisSupport support = new PostgisSupport();
/** /**
* Creates an instance * Creates an instance
*/ */
@ -33,7 +34,7 @@ public PostgisPG92Dialect() {
PGGeometryTypeDescriptor.INSTANCE.getSqlType(), PGGeometryTypeDescriptor.INSTANCE.getSqlType(),
"GEOMETRY" "GEOMETRY"
); );
for ( Map.Entry<String, StandardSQLFunction> entry : support.functionsToRegister() ) { for ( Map.Entry<String, SQLFunction> entry : support.functionsToRegister() ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -10,20 +10,21 @@
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.PostgreSQL93Dialect; import org.hibernate.dialect.PostgreSQL93Dialect;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
/** /**
* Extends the {@code PostgreSQL93Dialect} to add support for the Postgis spatial types, functions and operators . * Extends the {@code PostgreSQL93Dialect} to add support for the Postgis spatial types, functions and operators .
* * <p>
* Created by Karel Maesen, Geovise BVBA on 01/11/16. * Created by Karel Maesen, Geovise BVBA on 01/11/16.
*/ */
public class PostgisPG93Dialect extends PostgreSQL93Dialect implements SpatialDialect { public class PostgisPG93Dialect extends PostgreSQL93Dialect implements SpatialDialect {
private PostgisSupport support = new PostgisSupport(); transient private PostgisSupport support = new PostgisSupport();
/** /**
* Creates an instance * Creates an instance
*/ */
@ -33,7 +34,7 @@ public PostgisPG93Dialect() {
PGGeometryTypeDescriptor.INSTANCE.getSqlType(), PGGeometryTypeDescriptor.INSTANCE.getSqlType(),
"GEOMETRY" "GEOMETRY"
); );
for ( Map.Entry<String, StandardSQLFunction> entry : support.functionsToRegister() ) { for ( Map.Entry<String, SQLFunction> entry : support.functionsToRegister() ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -10,20 +10,21 @@
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
/** /**
* Extends the {@code PostgreSQL94Dialect} to add support for the Postgis spatial types, functions and operators . * Extends the {@code PostgreSQL94Dialect} to add support for the Postgis spatial types, functions and operators .
* * <p>
* Created by Karel Maesen, Geovise BVBA on 01/11/16. * Created by Karel Maesen, Geovise BVBA on 01/11/16.
*/ */
public class PostgisPG94Dialect extends PostgreSQL94Dialect implements SpatialDialect { public class PostgisPG94Dialect extends PostgreSQL94Dialect implements SpatialDialect {
private PostgisSupport support = new PostgisSupport(); transient private PostgisSupport support = new PostgisSupport();
/** /**
* Creates an instance * Creates an instance
*/ */
@ -33,7 +34,7 @@ public PostgisPG94Dialect() {
PGGeometryTypeDescriptor.INSTANCE.getSqlType(), PGGeometryTypeDescriptor.INSTANCE.getSqlType(),
"GEOMETRY" "GEOMETRY"
); );
for ( Map.Entry<String, StandardSQLFunction> entry : support.functionsToRegister() ) { for ( Map.Entry<String, SQLFunction> entry : support.functionsToRegister() ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -10,7 +10,7 @@
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.PostgreSQL95Dialect; import org.hibernate.dialect.PostgreSQL95Dialect;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
@ -22,7 +22,8 @@
public class PostgisPG95Dialect extends PostgreSQL95Dialect implements SpatialDialect { public class PostgisPG95Dialect extends PostgreSQL95Dialect implements SpatialDialect {
private PostgisSupport support = new PostgisSupport(); transient private PostgisSupport support = new PostgisSupport();
/** /**
* Creates an instance * Creates an instance
*/ */
@ -32,7 +33,7 @@ public PostgisPG95Dialect() {
PGGeometryTypeDescriptor.INSTANCE.getSqlType(), PGGeometryTypeDescriptor.INSTANCE.getSqlType(),
"GEOMETRY" "GEOMETRY"
); );
for ( Map.Entry<String, StandardSQLFunction> entry : support.functionsToRegister() ) { for ( Map.Entry<String, SQLFunction> entry : support.functionsToRegister() ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -10,20 +10,21 @@
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.PostgreSQL9Dialect; import org.hibernate.dialect.PostgreSQL9Dialect;
import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
/** /**
** Extends the {@code PostgreSQL9Dialect} to add support for the Postgis spatial types, functions and operators . * * Extends the {@code PostgreSQL9Dialect} to add support for the Postgis spatial types, functions and operators .
* * <p>
* Created by Karel Maesen, Geovise BVBA on 01/11/16. * Created by Karel Maesen, Geovise BVBA on 01/11/16.
*/ */
public class PostgisPG9Dialect extends PostgreSQL9Dialect implements SpatialDialect { public class PostgisPG9Dialect extends PostgreSQL9Dialect implements SpatialDialect {
private PostgisSupport support = new PostgisSupport(); transient private PostgisSupport support = new PostgisSupport();
/** /**
* Creates an instance * Creates an instance
*/ */
@ -33,7 +34,7 @@ public PostgisPG9Dialect() {
PGGeometryTypeDescriptor.INSTANCE.getSqlType(), PGGeometryTypeDescriptor.INSTANCE.getSqlType(),
"GEOMETRY" "GEOMETRY"
); );
for ( Map.Entry<String, StandardSQLFunction> entry : support.functionsToRegister() ) { for ( Map.Entry<String, SQLFunction> entry : support.functionsToRegister() ) {
registerFunction( entry.getKey(), entry.getValue() ); registerFunction( entry.getKey(), entry.getValue() );
} }
} }

View File

@ -6,6 +6,8 @@
*/ */
package org.hibernate.spatial.dialect.postgis; package org.hibernate.spatial.dialect.postgis;
import java.io.Serializable;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.GeolatteGeometryType; import org.hibernate.spatial.GeolatteGeometryType;
@ -18,7 +20,7 @@
/** /**
* Created by Karel Maesen, Geovise BVBA on 29/10/16. * Created by Karel Maesen, Geovise BVBA on 29/10/16.
*/ */
public class PostgisSupport implements SpatialDialect { public class PostgisSupport implements SpatialDialect, Serializable {
private PostgisFunctions postgisFunctions = new PostgisFunctions(); private PostgisFunctions postgisFunctions = new PostgisFunctions();