I create an entity object, and annotated it with @Index annotation. Application works, but in database not exist index I want. I tried both JPA and Hibernate annotations with no luck. This class placed in Spring boot 1.3.3.RELEASE application. In Maven dependencies I see hibernate-core-4.3.11.Final.jar and it maps to PostgreSQL 9.4.5. I tried different values for spring.jpa.hibernate.ddl-auto in application.properties file, like create, create-drop, update and even removed tables from database myself.
Please help: How to make application create index using annotations?
Update
I played with annotations and indexes created with same config. I cannot understand what differs. I only find that after I stop my application, and tables created in database it takes some time to see indexes update in pgAdmin. It looks like some cache update or so. Also I find that cannot create index with same name for different tables. Still cannot get what happen.
Update
Here entity class
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.jsoup.nodes.Element;
@Entity
@Table(indexes = { @Index(name = "job_id_idx", columnList = "job_id")})
public class JobLifeTime {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long code;
@Column(name="job_id", length=24)
private String targetJobCode;
@ManyToOne()
private ScraperTask scraperTask;
@Column(name="salary_low")
private Integer salaryMin;
@Column(name="salary_high")
private Integer salaryMax;
@Column(name="scrape_timestamp")
private Date scrapeTimestamp;
@Column(name="remove_timestamp")
private Date removeTimestamp;
public JobLifeTime(){}
//getters and setters ...
}