HHH-11087 - Fix missing type contribution in dialect
Also fixes broken integration tests
This commit is contained in:
parent
db7c6c58f1
commit
eada559ebe
|
@ -9,10 +9,9 @@ hibernate.test.new_metadata_mappings = true
|
|||
|
||||
hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect
|
||||
hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||
hibernate.connection.url jdbc:mysql://localhost/testhbs
|
||||
hibernate.connection.username hibernate
|
||||
hibernate.connection.password hibernate
|
||||
|
||||
hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com/test
|
||||
hibernate.connection.username hbs
|
||||
hibernate.connection.password
|
||||
|
||||
hibernate.connection.pool_size 5
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQL56SpatialDialect
|
||||
hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||
hibernate.connection.url jdbc:mysql://172.16.1.130/test
|
||||
hibernate.connection.username HBS
|
||||
hibernate.connection.password HBS
|
||||
hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:3306/test
|
||||
hibernate.connection.username hbs
|
||||
hibernate.connection.password
|
||||
|
||||
|
||||
hibernate.connection.pool_size 5
|
||||
|
|
|
@ -10,9 +10,9 @@ hibernate.test.new_metadata_mappings = true
|
|||
hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect
|
||||
hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||
|
||||
hibernate.connection.url jdbc:mysql://localhost/testhbs
|
||||
hibernate.connection.username hibernate
|
||||
hibernate.connection.password hibernate
|
||||
hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:3306/test
|
||||
hibernate.connection.username hbs
|
||||
hibernate.connection.password
|
||||
|
||||
|
||||
hibernate.connection.pool_size 5
|
||||
|
|
|
@ -14,8 +14,10 @@ package org.hibernate.spatial.dialect.mysql;
|
|||
import java.util.Map;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
import org.hibernate.spatial.SpatialRelation;
|
||||
|
@ -73,6 +75,19 @@ public class MySQL56SpatialDialect extends MySQL5Dialect implements SpatialDiale
|
|||
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
|
||||
public String getSpatialRelateSQL(String columnName, int spatialRelation) {
|
||||
switch ( spatialRelation ) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
|
@ -22,7 +23,6 @@ import java.sql.Statement;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.geolatte.geom.Geometry;
|
||||
|
@ -74,7 +74,12 @@ public class DataSourceUtils {
|
|||
* @param jdbcPass
|
||||
* @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.jdbcUrl = jdbcUrl;
|
||||
this.jdbcUser = jdbcUser;
|
||||
|
@ -110,15 +115,15 @@ public class DataSourceUtils {
|
|||
properties.load( is );
|
||||
return properties;
|
||||
}
|
||||
catch ( IOException e ) {
|
||||
throw ( new RuntimeException( e ) );
|
||||
catch (IOException e) {
|
||||
throw (new RuntimeException( e ));
|
||||
}
|
||||
finally {
|
||||
if ( is != null ) {
|
||||
try {
|
||||
is.close();
|
||||
}
|
||||
catch ( IOException e ) {
|
||||
catch (IOException e) {
|
||||
//nothing to do
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +146,7 @@ public class DataSourceUtils {
|
|||
* @throws SQLException
|
||||
*/
|
||||
public void close() throws SQLException {
|
||||
( (BasicDataSource) dataSource ).close();
|
||||
((BasicDataSource) dataSource).close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,7 +195,7 @@ public class DataSourceUtils {
|
|||
cn.close();
|
||||
}
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
catch (SQLException e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
@ -212,14 +217,18 @@ public class DataSourceUtils {
|
|||
stmt.close();
|
||||
LOG.info( "Loaded " + sum( insCounts ) + " rows." );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if ( cn != null ) {
|
||||
cn.close();
|
||||
}
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
// nothing to do
|
||||
catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +264,9 @@ public class DataSourceUtils {
|
|||
return sw.toString();
|
||||
}
|
||||
finally {
|
||||
if (reader != null) reader.close();
|
||||
if ( reader != null ) {
|
||||
reader.close();
|
||||
}
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
@ -287,7 +298,7 @@ public class DataSourceUtils {
|
|||
cn.close();
|
||||
}
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
catch (SQLException e) {
|
||||
} //do nothing.
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +334,7 @@ public class DataSourceUtils {
|
|||
}
|
||||
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
|
@ -331,14 +342,16 @@ public class DataSourceUtils {
|
|||
if ( results != null ) {
|
||||
results.close();
|
||||
}
|
||||
} catch (SQLException e){
|
||||
}
|
||||
catch (SQLException e) {
|
||||
//nothing to do
|
||||
}
|
||||
try {
|
||||
if ( pstmt != null ) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (SQLException e){
|
||||
}
|
||||
catch (SQLException e) {
|
||||
//nothing to do
|
||||
}
|
||||
try {
|
||||
|
@ -346,7 +359,7 @@ public class DataSourceUtils {
|
|||
cn.close();
|
||||
}
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
catch (SQLException e) {
|
||||
// nothing we can do.
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +384,7 @@ public class DataSourceUtils {
|
|||
try {
|
||||
result.put( testDataElement.id, decoder.decode( testDataElement.wkt ) );
|
||||
}
|
||||
catch ( WktDecodeException e ) {
|
||||
catch (WktDecodeException e) {
|
||||
System.out
|
||||
.println(
|
||||
String.format(
|
||||
|
|
|
@ -64,7 +64,7 @@ public class TestSupportFactories {
|
|||
"org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect".equals( canonicalName ) ) {
|
||||
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 ) ) {
|
||||
return MySQL56TestSupport.class;
|
||||
}
|
||||
|
|
|
@ -25,56 +25,56 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
|||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -75,9 +75,9 @@ hibernate.connection.password @jdbc.pass@
|
|||
##
|
||||
#hibernate.dialect org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect
|
||||
#hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||
#hibernate.connection.url jdbc:mysql://localhost/testhbs
|
||||
#hibernate.connection.username hibernate
|
||||
#hibernate.connection.password hibernate
|
||||
#hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com/test
|
||||
#hibernate.connection.username hbs
|
||||
#hibernate.connection.password
|
||||
|
||||
##
|
||||
## MySQL 5 InnoDDB dialect
|
||||
|
@ -91,8 +91,8 @@ hibernate.connection.password @jdbc.pass@
|
|||
##
|
||||
## 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.url jdbc:mysql://172.16.1.130/test
|
||||
#hibernate.connection.username HBS
|
||||
#hibernate.connection.password HBS
|
||||
#hibernate.connection.url jdbc:mysql://hibernate-spatial-integration.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:3306/test
|
||||
#hibernate.connection.username hbs
|
||||
#hibernate.connection.password
|
||||
|
|
Loading…
Reference in New Issue