Plugins You can find out about all the publicly available Grails plugins.

Hibernate Spatial Grails Plugin

  • Tags: hibernate spatial
  • Latest: 0.0.4
  • Last Updated: 30 September 2011
  • Grails version: 1.2.0 > *
  • Authors: Daniel Henrique Alves Lima
0 vote
compile "org.grails.plugins:hibernate-spatial:0.0.4"

 Documentation  Source



One of the following:

grails install-plugin hibernate-spatial-hdb
grails install-plugin hibernate-spatial-mysql
grails install-plugin hibernate-spatial-oracle
grails install-plugin hibernate-spatial-postgresql
grails install-plugin hibernate-spatial-sqlserver

Project at GitHub is grails-hibernate-spatial-plugin


It provides support for using the Hibernate Spatial in Grails.

How it works

The core plugin is not for direct use. There is a child plugin for each Provider supported by Hibernate Spatial:

The integration is very simple. A child plugin will automatically:
  • Register new Hibernate custom user types in Config.groovy;
/* Added by the Hibernate Spatial Plugin. */
grails.gorm.default.mapping = {
   'user-type'(type:org.hibernatespatial.GeometryUserType, class:com.vividsolutions.jts.geom.Geometry)
   'user-type'(type:org.hibernatespatial.GeometryUserType, class:com.vividsolutions.jts.geom.GeometryCollection)
   // Additional user-type mappings
  • Change the Hibernate Dialect and the JDBC Driver class in DataSource(s).groovy;
/* Added by the Hibernate Spatial Plugin. */
dataSource {
   driverClassName = // Suitable JDBC Driver
   dialect = // Suitable Hibernate Spatial Dialect
  • Define repositories and resolve library dependencies.
// plugin's BuildConfig.groovy
repositories {
   // (...)

mavenRepo '' mavenRepo '' }

dependencies { // Suitable dependencies for this Provider }

Basic usage

  • Install the appropriate child plugin;
  • Create a spatially enabled database;
  • Configure the corresponding JDBC Driver dependency in BuildConfig.groovy;
  • Change the JDBC URL in DataSource(s).groovy;
  • In your domain classes, define properties of the type com.vividsolutions.jts.geom.Geometry (or subclasses);
  • Perform some tests using save, dynamic finders, HQL and Criteria.