2 Replies Latest reply on Oct 13, 2008 3:08 AM by Georges Berscheid

    @Index annotation

    Georges Berscheid Newbie

      Hi,

      I'm trying to use the @Index annotation with EJB3 in Hibernate 3.2.6.ga to create indexes automatically when an entity is deployed. According to the documentation it can be put either into the @org.hibernate.annotations.Table annotation or directly on the entity property.

      Unfortunately, neither

      @javax.persistence.Table(name = "records")
      @org.hibernate.annotations.Table(appliesTo = "records", indexes = { @Index(name = "IDX", columnNames = { "timestamp" }) })
      

      nor
      @Index(name = "IDX", columnNames = { "timestamp" })
      public Date getTimestamp() {
       return timestamp;
      }
      
      nor
      @Index(name = "IDX")
      public Date getTimestamp() {
       return timestamp;
      }
      
      seem to work.

      It does create the table on deploy, creates all the foreign keys associated with the entity, creates indexes on the foreign key columns, but the indexes specified using @Index are missing.

      Any hints?

      Thanks a lot,
      Georges