Reputation: 1152
How do I properly annotate a PostgreSQL GIN index with Hibernate?
@Index(...)
String text;
Does hibernate create a GIN index by default, or do I have to set a special property somewhere?
Upvotes: 5
Views: 2240
Reputation: 325241
Looks like you can't create custom indexes directly with Hibernate's annotations. See related: How to use Hibernate Annotations to add an index on a Lob / Clob / tinyblob, where an answer mentions how to do it with auxillary objects.
In your situation I would query the system catalogs (information_schema
or pg_catalog
) for the index at startup and, if it wasn't found, execute CREATE INDEX
statement with native SQL.
See this answer to a very similar question about creating triggers in Hibernate.
Upvotes: 3