I'm using (spatial) hibernate annotations to create a schema for a spatial application that is implemented on top of PostGIS. When creating the database schema from my annotated classes, I'm in need to create spatial indexes for speeding up spatial queries that are used throughout the application.
@Entity
@Table(name = "MY_CLASS")
@org.hibernate.annotations.Table(
appliesTo = "MY_CLASS", indexes = {
@Index(name = "idx_my_class_sidx",
columnNames = { "GEOM" }) })
public class MyClass {
[...]
@Column(name = "GEOM")
@Type(type = "org.hibernate.spatial.GeometryType")
private LineString geom;
[...]
}
While the exported schema contains the index, unfortunately it has been created with an undesired index method; hibernate seems to default to btree
however PostGIS recommends the use of GIST
indexes when dealing with spatial data (see http://postgis.net/docs/manual-2.0/using_postgis_dbmanagement.html#id441511).
CREATE INDEX idx_my_class_sidx
ON my_class
USING btree
(geom);
Whereas I might just fall back creating the index with plain SQL, I'm wondering if there is a way to use hibernate annotations to override the default method type for PostgreSQL? Solutions or even ideas how to do that would be highly appreciated.
TIA, Tilman