I’m using hibernate with hbm2ddl.auto=update so that it’ll automatically generate my oracle tables for me (i’ve no intention of learning oracle’s sql).
So far, so good, until now i’m trying to get it to create an index. As far as i can tell, i’ve made my annotations correctly:
package data;
import javax.persistence.*;
import org.hibernate.annotations.Index;
@Entity
@Table(name="log_entries")
@org.hibernate.annotations.Table(appliesTo="log_entries",
indexes = { @Index(name="idx", columnNames = {"job", "version", "schedule", "dttmRun", "pid" } ) } )
public class LogEntry {
@Id @GeneratedValue
Long id;
String job;
String version;
String schedule;
String dttmRun;
int pid;
String command;
int duration;
// getters and setters...
}
When i drop the table and restart my app, it creates the table but not the index. Any ideas?
I tested your code on Derby and here is what I get when running
SchemaUpdateSchemaExport:Works as expected. Can’t try on Oracle right now though.Tested with Hibernate EM 3.4.0.GA, Hibernate Annotations 3.4.0.GA, Hibernate Core 3.3.0.SP1.
Update: I realized I ran
SchemaExport, notSchemaUpdateand confirm the index didn’t get created when runningSchemaUpdatewith the versions of libraries mentioned above. So, whileANN-108has been rejected as a dupe ofHHH-1012, whileHHH-1012is marked as fixed, while HB-1458 is open (!?), my quick test didn’t work as expected. I’ll take a deeper look later but I’m very confused now (especially by HHH-1012).