6

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?

0

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.