1

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.

ljgw
  • 2,751
  • 1
  • 20
  • 39
j.bergmann
  • 41
  • 7
  • 1
    I found appoximately the same question here: http://stackoverflow.com/questions/12025844/how-to-annotate-unique-constraint-with-where-clause-in-jpa. The answer should be very helpful. – ljgw Oct 28 '13 at 08:36

0 Answers0