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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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_schemaorpg_catalog) for the index at startup and, if it wasn’t found, executeCREATE INDEXstatement with native SQL.See this answer to a very similar question about creating triggers in Hibernate.