diff --git a/hibernate-spatial/databases/mysql5/resources/hibernate.properties b/hibernate-spatial/databases/mysql5/resources/hibernate.properties index 80d04cddd0..1b9f49c186 100644 --- a/hibernate-spatial/databases/mysql5/resources/hibernate.properties +++ b/hibernate-spatial/databases/mysql5/resources/hibernate.properties @@ -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 diff --git a/hibernate-spatial/databases/mysql56/resources/hibernate.properties b/hibernate-spatial/databases/mysql56/resources/hibernate.properties index 75b646e9da..4076167dd7 100644 --- a/hibernate-spatial/databases/mysql56/resources/hibernate.properties +++ b/hibernate-spatial/databases/mysql56/resources/hibernate.properties @@ -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 diff --git a/hibernate-spatial/databases/mysql5_innodb/resources/hibernate.properties b/hibernate-spatial/databases/mysql5_innodb/resources/hibernate.properties index c8aeaecfac..ba3506aa95 100644 --- a/hibernate-spatial/databases/mysql5_innodb/resources/hibernate.properties +++ b/hibernate-spatial/databases/mysql5_innodb/resources/hibernate.properties @@ -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 diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mysql/MySQL56SpatialDialect.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mysql/MySQL56SpatialDialect.java index b0dae34aba..a0d7dfd7cf 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mysql/MySQL56SpatialDialect.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mysql/MySQL56SpatialDialect.java @@ -8,14 +8,16 @@ package org.hibernate.spatial.dialect.mysql; /** * @author Karel Maesen, Geovise BVBA - * creation-date: 10/9/13 + * creation-date: 10/9/13 */ 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 ) { diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/DataSourceUtils.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/DataSourceUtils.java index 5262a5ce26..c886c9967f 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/DataSourceUtils.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/DataSourceUtils.java @@ -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( diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/TestSupportFactories.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/TestSupportFactories.java index ebc61c8f1f..3776f7aa50 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/TestSupportFactories.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/TestSupportFactories.java @@ -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; } diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/mysql/MySQL56ExpectationsFactory.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/mysql/MySQL56ExpectationsFactory.java index 8bd0f1f199..8887ee4e46 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/mysql/MySQL56ExpectationsFactory.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/dialects/mysql/MySQL56ExpectationsFactory.java @@ -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()); } diff --git a/hibernate-spatial/src/test/resources/hibernate.properties b/hibernate-spatial/src/test/resources/hibernate.properties index 28817f6644..e19c851f5f 100644 --- a/hibernate-spatial/src/test/resources/hibernate.properties +++ b/hibernate-spatial/src/test/resources/hibernate.properties @@ -74,9 +74,9 @@ hibernate.connection.username sa ## #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 @@ -90,8 +90,8 @@ hibernate.connection.username sa ## ## 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