Hibernate Spatial Postgis Provider Usage

To have Hibernate Spatial use this provider, simply drop the jar on the class-path alongside the hibernate-spatial.jar. When the Hibernate Spatial library is loaded it will find the provider and use it to retrieve the Hibernate dialect for Postgresql with the Postgis extension. This dialect is a subclass of org.hibernate.dialect.PostgreSQLDialect

With the provider installed, you can use it by setting the dialect in the Hibernate configuration file as in the following snippet.

                ...
                <property name="hibernate.dialect">
                    org.hibernatespatial.postgis.PostgisDialect
                </property>
                ...
            

When there is more than one Hibernate Spatial provider on the Class-Path, you should explicitly label the dialect for the Geometry valued properties.

                ...
                <property name="geometry">
                    <type name="org.hibernatespatial.GeometryUserType">
                        <param name="dialect">postgis</param>
                    </type>
                    <column name="geom" />
                </property>
                ...