HHH-11087 - Fix missing type contribution in dialect
Also fixes broken integration tests
This commit is contained in:
parent
872848908f
commit
7c5f1aabb3
|
@ -9,10 +9,9 @@ hibernate.test.new_metadata_mappings = true
|
||||||
|
|
||||||
hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect
|
hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect
|
||||||
hibernate.connection.driver_class com.mysql.jdbc.Driver
|
hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||||
hibernate.connection.url jdbc:mysql://localhost/testhbs
|
hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com/test
|
||||||
hibernate.connection.username hibernate
|
hibernate.connection.username hbs
|
||||||
hibernate.connection.password hibernate
|
hibernate.connection.password
|
||||||
|
|
||||||
|
|
||||||
hibernate.connection.pool_size 5
|
hibernate.connection.pool_size 5
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQL56SpatialDialect
|
hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQL56SpatialDialect
|
||||||
hibernate.connection.driver_class com.mysql.jdbc.Driver
|
hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||||
hibernate.connection.url jdbc:mysql://172.16.1.130/test
|
hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:3306/test
|
||||||
hibernate.connection.username HBS
|
hibernate.connection.username hbs
|
||||||
hibernate.connection.password HBS
|
hibernate.connection.password
|
||||||
|
|
||||||
|
|
||||||
hibernate.connection.pool_size 5
|
hibernate.connection.pool_size 5
|
||||||
|
|
|
@ -10,9 +10,9 @@ hibernate.test.new_metadata_mappings = true
|
||||||
hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect
|
hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect
|
||||||
hibernate.connection.driver_class com.mysql.jdbc.Driver
|
hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||||
|
|
||||||
hibernate.connection.url jdbc:mysql://localhost/testhbs
|
hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:3306/test
|
||||||
hibernate.connection.username hibernate
|
hibernate.connection.username hbs
|
||||||
hibernate.connection.password hibernate
|
hibernate.connection.password
|
||||||
|
|
||||||
|
|
||||||
hibernate.connection.pool_size 5
|
hibernate.connection.pool_size 5
|
||||||
|
|
|
@ -8,14 +8,16 @@ package org.hibernate.spatial.dialect.mysql;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Karel Maesen, Geovise BVBA
|
* @author Karel Maesen, Geovise BVBA
|
||||||
* creation-date: 10/9/13
|
* creation-date: 10/9/13
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
import org.hibernate.dialect.MySQL5Dialect;
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||||
|
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;
|
||||||
import org.hibernate.spatial.SpatialRelation;
|
import org.hibernate.spatial.SpatialRelation;
|
||||||
|
@ -73,6 +75,19 @@ public class MySQL56SpatialDialect extends MySQL5Dialect implements SpatialDiale
|
||||||
return dialectDelegate.getTypeName( code, length, precision, scale );
|
return dialectDelegate.getTypeName( code, length, precision, scale );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the Dialect to contribute additional types
|
||||||
|
*
|
||||||
|
* @param typeContributions Callback to contribute the types
|
||||||
|
* @param serviceRegistry The service registry
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void contributeTypes(
|
||||||
|
TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
|
super.contributeTypes( typeContributions, serviceRegistry );
|
||||||
|
dialectDelegate.contributeTypes( typeContributions, serviceRegistry );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSpatialRelateSQL(String columnName, int spatialRelation) {
|
public String getSpatialRelateSQL(String columnName, int spatialRelation) {
|
||||||
switch ( spatialRelation ) {
|
switch ( spatialRelation ) {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
package org.hibernate.spatial.testing;
|
package org.hibernate.spatial.testing;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -22,7 +23,6 @@ import java.sql.Statement;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp.BasicDataSource;
|
||||||
import org.geolatte.geom.Geometry;
|
import org.geolatte.geom.Geometry;
|
||||||
|
@ -74,7 +74,12 @@ public class DataSourceUtils {
|
||||||
* @param jdbcPass
|
* @param jdbcPass
|
||||||
* @param sqlExpressionTemplate SQLExpressionTemplate object that generates SQL statements for this database
|
* @param sqlExpressionTemplate SQLExpressionTemplate object that generates SQL statements for this database
|
||||||
*/
|
*/
|
||||||
public DataSourceUtils(String jdbcDriver, String jdbcUrl, String jdbcUser, String jdbcPass, SQLExpressionTemplate sqlExpressionTemplate) {
|
public DataSourceUtils(
|
||||||
|
String jdbcDriver,
|
||||||
|
String jdbcUrl,
|
||||||
|
String jdbcUser,
|
||||||
|
String jdbcPass,
|
||||||
|
SQLExpressionTemplate sqlExpressionTemplate) {
|
||||||
this.jdbcDriver = jdbcDriver;
|
this.jdbcDriver = jdbcDriver;
|
||||||
this.jdbcUrl = jdbcUrl;
|
this.jdbcUrl = jdbcUrl;
|
||||||
this.jdbcUser = jdbcUser;
|
this.jdbcUser = jdbcUser;
|
||||||
|
@ -110,15 +115,15 @@ public class DataSourceUtils {
|
||||||
properties.load( is );
|
properties.load( is );
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
catch ( IOException e ) {
|
catch (IOException e) {
|
||||||
throw ( new RuntimeException( e ) );
|
throw (new RuntimeException( e ));
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( is != null ) {
|
if ( is != null ) {
|
||||||
try {
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
catch ( IOException e ) {
|
catch (IOException e) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +146,7 @@ public class DataSourceUtils {
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void close() throws SQLException {
|
public void close() throws SQLException {
|
||||||
( (BasicDataSource) dataSource ).close();
|
((BasicDataSource) dataSource).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,7 +195,7 @@ public class DataSourceUtils {
|
||||||
cn.close();
|
cn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( SQLException e ) {
|
catch (SQLException e) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,14 +217,18 @@ public class DataSourceUtils {
|
||||||
stmt.close();
|
stmt.close();
|
||||||
LOG.info( "Loaded " + sum( insCounts ) + " rows." );
|
LOG.info( "Loaded " + sum( insCounts ) + " rows." );
|
||||||
}
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
if ( cn != null ) {
|
if ( cn != null ) {
|
||||||
cn.close();
|
cn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( SQLException e ) {
|
catch (SQLException e) {
|
||||||
// nothing to do
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +264,9 @@ public class DataSourceUtils {
|
||||||
return sw.toString();
|
return sw.toString();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (reader != null) reader.close();
|
if ( reader != null ) {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,7 +298,7 @@ public class DataSourceUtils {
|
||||||
cn.close();
|
cn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( SQLException e ) {
|
catch (SQLException e) {
|
||||||
} //do nothing.
|
} //do nothing.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,7 +334,7 @@ public class DataSourceUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( SQLException e ) {
|
catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -331,14 +342,16 @@ public class DataSourceUtils {
|
||||||
if ( results != null ) {
|
if ( results != null ) {
|
||||||
results.close();
|
results.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e){
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if ( pstmt != null ) {
|
if ( pstmt != null ) {
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e){
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -346,7 +359,7 @@ public class DataSourceUtils {
|
||||||
cn.close();
|
cn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( SQLException e ) {
|
catch (SQLException e) {
|
||||||
// nothing we can do.
|
// nothing we can do.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,7 +384,7 @@ public class DataSourceUtils {
|
||||||
try {
|
try {
|
||||||
result.put( testDataElement.id, decoder.decode( testDataElement.wkt ) );
|
result.put( testDataElement.id, decoder.decode( testDataElement.wkt ) );
|
||||||
}
|
}
|
||||||
catch ( WktDecodeException e ) {
|
catch (WktDecodeException e) {
|
||||||
System.out
|
System.out
|
||||||
.println(
|
.println(
|
||||||
String.format(
|
String.format(
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class TestSupportFactories {
|
||||||
"org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect".equals( canonicalName ) ) {
|
"org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect".equals( canonicalName ) ) {
|
||||||
return MySQLTestSupport.class;
|
return MySQLTestSupport.class;
|
||||||
}
|
}
|
||||||
if ( "org.hibernate.spatial.dialect.mysql.MySQLSpatial56Dialect".equals( canonicalName ) ||
|
if ( "org.hibernate.spatial.dialect.mysql.MySQL56SpatialDialect".equals( canonicalName ) ||
|
||||||
"org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect".equals( canonicalName ) ) {
|
"org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect".equals( canonicalName ) ) {
|
||||||
return MySQL56TestSupport.class;
|
return MySQL56TestSupport.class;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,56 +25,56 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
||||||
@Override
|
@Override
|
||||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||||
return createNativeSQLStatementAllWKTParams(
|
return createNativeSQLStatementAllWKTParams(
|
||||||
"select t.id, ST_Touches(t.geom, GeomFromText(?, 4326)) from GEOMTEST t where ST_Touches(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
"select t.id, ST_Touches(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Touches(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||||
geom.toText());
|
geom.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||||
return createNativeSQLStatementAllWKTParams(
|
return createNativeSQLStatementAllWKTParams(
|
||||||
"select t.id, ST_overlaps(t.geom, GeomFromText(?, 4326)) from GEOMTEST t where ST_Overlaps(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
"select t.id, ST_overlaps(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Overlaps(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||||
geom.toText());
|
geom.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||||
return createNativeSQLStatementAllWKTParams(
|
return createNativeSQLStatementAllWKTParams(
|
||||||
"select t.id, ST_Intersects(t.geom, GeomFromText(?, 4326)) from GEOMTEST t where ST_Intersects(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
"select t.id, ST_Intersects(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Intersects(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||||
geom.toText());
|
geom.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||||
return createNativeSQLStatementAllWKTParams(
|
return createNativeSQLStatementAllWKTParams(
|
||||||
"select t.id, ST_Within(t.geom, GeomFromText(?, 4326)) from GEOMTEST t where ST_Within(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
"select t.id, ST_Within(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Within(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||||
geom.toText());
|
geom.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||||
return createNativeSQLStatementAllWKTParams(
|
return createNativeSQLStatementAllWKTParams(
|
||||||
"select t.id, ST_Equals(t.geom, GeomFromText(?, 4326)) from GEOMTEST t where ST_Equals(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
"select t.id, ST_Equals(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Equals(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||||
geom.toText());
|
geom.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||||
return createNativeSQLStatementAllWKTParams(
|
return createNativeSQLStatementAllWKTParams(
|
||||||
"select t.id, ST_Crosses(t.geom, GeomFromText(?, 4326)) from GEOMTEST t where ST_Crosses(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
"select t.id, ST_Crosses(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Crosses(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||||
geom.toText());
|
geom.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||||
return createNativeSQLStatementAllWKTParams(
|
return createNativeSQLStatementAllWKTParams(
|
||||||
"select t.id, ST_Contains(t.geom, GeomFromText(?, 4326)) from GEOMTEST t where ST_Contains(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
"select t.id, ST_Contains(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Contains(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||||
geom.toText());
|
geom.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||||
return createNativeSQLStatementAllWKTParams(
|
return createNativeSQLStatementAllWKTParams(
|
||||||
"select t.id, ST_Disjoint(t.geom, GeomFromText(?, 4326)) from GEOMTEST t where ST_Disjoint(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
"select t.id, ST_Disjoint(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Disjoint(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||||
geom.toText());
|
geom.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,9 @@ hibernate.connection.username sa
|
||||||
##
|
##
|
||||||
#hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect
|
#hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect
|
||||||
#hibernate.connection.driver_class com.mysql.jdbc.Driver
|
#hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||||
#hibernate.connection.url jdbc:mysql://localhost/testhbs
|
#hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com/test
|
||||||
#hibernate.connection.username hibernate
|
#hibernate.connection.username hbs
|
||||||
#hibernate.connection.password hibernate
|
#hibernate.connection.password
|
||||||
|
|
||||||
##
|
##
|
||||||
## MySQL 5 InnoDDB dialect
|
## MySQL 5 InnoDDB dialect
|
||||||
|
@ -90,8 +90,8 @@ hibernate.connection.username sa
|
||||||
##
|
##
|
||||||
## MySQL 5.6.1 dialect
|
## MySQL 5.6.1 dialect
|
||||||
##
|
##
|
||||||
#hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQL56SpatialDialect
|
#hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect
|
||||||
#hibernate.connection.driver_class com.mysql.jdbc.Driver
|
#hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||||
#hibernate.connection.url jdbc:mysql://172.16.1.130/test
|
#hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:3306/test
|
||||||
#hibernate.connection.username HBS
|
#hibernate.connection.username hbs
|
||||||
#hibernate.connection.password HBS
|
#hibernate.connection.password
|
||||||
|
|
Loading…
Reference in New Issue