Hibernate Unique Indices with condition

592 Views Asked by At

I am using Hibernate 3.6 with anontations, JPA and a postgres database.
I am trying to set up an index for a table containing several columns and a condition on one column.

The SQL is supposed to look like this:

CREATE UNIQUE INDEX index_name_idx ON table_name (column1, column2, column3) WHERE column3 = '1' 

My code looks like this:

@Table(name = "person", schema = "public", uniqueConstraints =
{
      @UniqueConstraint(columnNames =
          {
             "name", "firstname", "active"  
          }),  
})  

is there a possibility to get the WHERE condition into this?

If not I will have to change the index with native SQL, but I would rather have a solution with annotations.

0

There are 0 best solutions below