I've gone through the documentation, Jira and the forums and I can't seem to find a good answer on this issue.
I have a mapping file with two indexes. They get created or put in the generated SQL script if I use the SchemaExportTask.
If I use hibernate.hbm2ddl.auto=update in my Hibernate properties the tables, keys and foreign keys are created correctly but the indexes are not created.
I've found a few forum posts that touch on the issue but nothing conclusive. There is also a year old issue in Jira but it is referring to MySQL:
http://opensource.atlassian.com/project ... se/HB-1458
I'm using:
Implementation-Title: Hibernate3
Implementation-Version: 3.2.0.cr2
Implementation-Vendor: hibernate.org
Hibernate-Version: 3.2.0.cr2
My mapping file is:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false" default-cascade="all-delete-orphan">
<class name="edu.wisc.my.portlets.bookmarks.domain.Entry" table="BOOKMARK_STORE">
<id name="id" type="long" unsaved-value="-1">
<column name="ENTRY_ID" not-null="true"/>
<generator class="native"/>
</id>
<discriminator type="string">
<column name="ENTRY_TYPE" length="64" index="BM_EntryTypeIdx"/>
</discriminator>
<property name="name" type="string">
<column name="NAME" length="4000" index="BM_EntryNameIdx"/>
</property>
<property name="note" type="string">
<column name="NOTE" length="4000"/>
</property>
<property name="created" type="java.util.Date">
<column name="CREATED" not-null="true"/>
</property>
<property name="modified" type="java.util.Date">
<column name="MODIFIED" not-null="true"/>
</property>
<subclass name="edu.wisc.my.portlets.bookmarks.domain.Folder" discriminator-value="FOLDER">
<map name="children" fetch="join" optimistic-lock="false">
<key>
<column name="PARENT_FOLDER_ID" not-null="false"/>
</key>
<map-key type="long">
<formula>ENTRY_ID</formula>
</map-key>
<one-to-many class="edu.wisc.my.portlets.bookmarks.domain.Entry" not-found="ignore"/>
</map>
<!-- TODO figure out how to persist comparator -->
<property name="minimized" type="true_false">
<column name="MINIMIZED"/>
</property>
<subclass name="edu.wisc.my.portlets.bookmarks.domain.BookmarkSet" discriminator-value="BOOKMARK_SET">
<property name="owner" type="string">
<column name="OWNER" length="500" index="BM_EntryNameIdx"/>
</property>
</subclass>
</subclass>
<subclass name="edu.wisc.my.portlets.bookmarks.domain.Bookmark" discriminator-value="BOOKMARK">
<property name="url" type="string">
<column name="URL" length="4000"/>
</property>
<property name="newWindow" type="true_false">
<column name="NEW_WINDOW"/>
</property>
</subclass>
</class>
</hibernate-mapping>
The SQL generated by SchemaExportTask is:
Code:
create table BOOKMARK_PREFS (PREF_ID number(19,0) not null, NAME varchar2(4000 char), OWNER varchar2(500 char), DEFAULT_FOLDER_OPERATION varchar2(64 char), primary key (PREF_ID));
create table BOOKMARK_STORE (ENTRY_ID number(19,0) not null, ENTRY_TYPE varchar2(64 char) not null, NAME varchar2(4000 char), NOTE varchar2(4000 char), CREATED timestamp not null, MODIFIED timestamp not null, MINIMIZED char(1 char), OWNER varchar2(500 char), URL varchar2(4000 char), NEW_WINDOW char(1 char), PARENT_FOLDER_ID number(19,0), primary key (ENTRY_ID));
create index BM_PrefNameIdx on BOOKMARK_PREFS (NAME, OWNER);
create index BM_EntryNameIdx on BOOKMARK_STORE (NAME, OWNER);
create index BM_EntryTypeIdx on BOOKMARK_STORE (ENTRY_TYPE);
alter table BOOKMARK_STORE add constraint FK604FB878197C2B7 foreign key (PARENT_FOLDER_ID) references BOOKMARK_STORE;
create sequence hibernate_sequence;
The SQL generated by SchemaUpdate is:
Code:
create table BOOKMARK_PREFS (PREF_ID number(19,0) not null, NAME varchar2(4000 char), OWNER varchar2(500 char), DEFAULT_FOLDER_OPERATION varchar2(64 char), primary key (PREF_ID))
create table BOOKMARK_STORE (ENTRY_ID number(19,0) not null, ENTRY_TYPE varchar2(64 char) not null, NAME varchar2(4000 char), NOTE varchar2(4000 char), CREATED timestamp not null, MODIFIED timestamp not null, MINIMIZED char(1 char), OWNER varchar2(500 char), URL varchar2(4000 char), NEW_WINDOW char(1 char), PARENT_FOLDER_ID number(19,0), primary key (ENTRY_ID))
alter table BOOKMARK_STORE add constraint FK604FB878197C2B7 foreign key (PARENT_FOLDER_ID) references BOOKMARK_STORE
schema update complete