My tools -> Java 8, JPA 2.1 and Hibernate 4. Im using just JPA2.1 annotations.
The code in the dock ->
@Entity
@Table(indexes = { @Index(name = INDEX_PK, columnList = ID) })
public class Invoice {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = DEF_GEN_NAME)
@SequenceGenerator(sequenceName = DEF_SEQUENCE_NAME, name = DEF_GEN_NAME, allocationSize =
ALLOCATION_SIZE)
@Column(name = ID)
private Long id = 0L;
}
When schemma is being created by Hibernate (hbm2ddl="create-drop"), i get the following Oracle error:
Hibernate: create index INVOICE_ID_PK on Invoice (ID)
sep 14, 2014 7:00:53 AM org.hibernate.tool.hbm2ddl.SchemaExport perform
ERROR: HHH000389: Unsuccessful: create index INVOICE_ID_PK on Invoice (ID)
sep 14, 2014 7:00:53 AM org.hibernate.tool.hbm2ddl.SchemaExport perform
ERROR: ORA-01408: such column list already indexed
Searching for this issue y found that index on primary keys are default generated by Oracle itself, Hibernate is unaware of this behavior, fact is that hibernate first create table Invoice, so Oracle automatically create a index called sysXXX (example: SYS_C0011010) for id on tha table Invoice.
After all tables are created Hibernate begin to create indexes, then Oracle throw an error for
duplicating an index on same column ID
Is there a way to alter this behavior to create the index and table in same SQL statement by Hibernate?..any walkaround?
Thanks!