I am using Hibernate to talk to my DB. I have one field that is an enumeration and it is going to be used in a slow query. So I'd like to index it. I've put the following annotations on the field:
@Column(name="RIGHT_TYPE", unique=false, nullable=false, length=10)
@Enumerated(EnumType.STRING)
@Index(name = "ABC_INDEX")
protected RightType rightType;
However, I don't see any index on that field created.
I'm using org.hibernate.dialect.Oracle9Dialect
. The (trimmed down) ddl is:
create table DOCUMENTS (documentID varchar2(255 char) not null, owner_principalId varchar2(255 char), primary key (documentID))
create table DOC_RIGHTS (document raw(255) not null, primary key (document))
create table PRINCIPAL (TYPE varchar2(31 char) not null, principalId varchar2(255 char) not null, displayName varchar2(255 char), primary key (principalId))
create table PRINCIPAL_RIGHTS (id varchar2(255 char) not null, PRINCIPAL_ID varchar2(255 char) unique, DOCUMENT_RIGHT_ID raw(255) unique, primary key (id))
create table RIGHTS (TYPE varchar2(31 char) not null, id number(19,0) not null, RIGHT_TYPE varchar2(10 char) not null, PRINCIPAL_RIGHT_ID varchar2(255 char) unique, primary key (id))
create table ROLE_MAP (PRINCIPAL_ID varchar2(255 char) not null, ROLE_ID varchar2(255 char) not null)
alter table DOCUMENTS add constraint FKDC2BB35E362547 foreign key (owner_principalId) references PRINCIPAL
create index PRINCIPAL_INDEX on PRINCIPAL_RIGHTS (PRINCIPAL_ID)
alter table PRINCIPAL_RIGHTS add constraint FKB32239ADFB30571B foreign key (PRINCIPAL_ID) references PRINCIPAL
alter table PRINCIPAL_RIGHTS add constraint FKB32239ADE1F0C813 foreign key (DOCUMENT_RIGHT_ID) references DOC_RIGHTS
create index RIGHT_TYPE_INDEX on RIGHTS (RIGHT_TYPE)
alter table RIGHTS add constraint FKF34FBA9CA09D6215 foreign key (PRINCIPAL_RIGHT_ID) references PRINCIPAL_RIGHTS
alter table ROLE_MAP add constraint FKA413CD78FB30571B foreign key (PRINCIPAL_ID) references PRINCIPAL
alter table ROLE_MAP add constraint FKA413CD7883A04939 foreign key (ROLE_ID) references PRINCIPAL
create sequence RIGHTS_SEQUENCE
But I can create one manually if I wish so. Why is that? Is there any way to force Hibernate to make it happen?