I'm trying to add a Point to a domain object in Grails 3.3.8 (current latest release). Grails 3.3.8 uses Hibernate 5.1.5, which has support for hibernate-spatial.
In build.gradle:
compile group: 'org.hibernate', name: 'hibernate-spatial', version: '5.1.5.Final'
compile group: 'com.vividsolutions', name: 'jts', version: '1.13'
In config:
driverClassName = 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
dialect = 'org.hibernate.dialect.SqlServer2008SpatialDialect'
In domain, PointTest.groovy:
package com.test
import com.vividsolutions.jts.geom.Point
class PointTest {
Point coords
static constraints = {
}
static mapping = {
coords sqlType: 'geometry(Point,4326)'
}
}
From what I can tell from this post on Stack Overflow, the above should work. But when I run the Grails project, the table is not created. If I remove the line from mapping
, the table is created, but coords
is of the wrong type, varbinary(255)
.
Java version: 8
Grails version: 3.3.8
Database version: SQL Server 2017
dialect = 'org.hibernate.dialect.SqlServer2008SpatialDialect'
should instead be
dialect = 'org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect'
The SRID is set per object and not initialized as part of the column type.