SchemaUpdate does not create column indexes (MySql)

Description

From forum thread: http://forum.hibernate.org/viewtopic.php?t=939655

SchemaUpdate is failing to create indices specified using the <column> element in the mapping file. There is no error message generated. If I repeat the same test with the SchemaExport utility, the indices are created successfully.

I include:

1) A mapping file that demonstrates the problem. This is a modified version of Simple.hbm.xml included in the Hibernate 2.1.8 distribution.
2) SQL sent to the server by SchemaUpdate (starting with a clean DB).
3) For comparison, the SQL sent to the server by SchemaExport (starting with a clean DB).

Mapping file:

<hibernate-mapping>
<class name="org.hibernate.test.Simple">
<id type="long" column="id_">
<generator class="assigned"/>
</id>
<!-- BEGIN MODIFICATION -->
<property name="name">
<column name="name"
index="test_idx" />
</property>
<!-- END MODIFICATION -->
<property name="address"/>
<property name="count" column="count_" not-null="true" unique="true"/>
<property name="date" column="date_"/>
<property name="pay"/>
<many-to-one name="other" access="field"/>
</class>
</hibernate-mapping>

Result:

The table is created successfully, the primary key is created successfully, but no index on the column 'name' is created.

SQL sent to server by SchemaUpdate:

050309 15:42:57 69 Init DB test
69 Query select round('inf'), round('-inf'), round('nan')
69 Query SHOW VARIABLES
69 Query SET autocommit=1
69 Query SET autocommit=0
69 Query commit
69 Query SET autocommit=1
69 Query SHOW TABLES FROM `test` LIKE 'Simple'
69 Query SHOW TABLES FROM `test` LIKE 'Simple'
69 Query create table Simple (id_ bigint not null, name varchar(255), address varchar(255), count_ integer not null unique, date_ datetime, pay float, other bigint, primary key (id_))
69 Query alter table Simple add index FK939D1DD26527F10 (other), add constraint FK939D1DD26527F10 foreign key (other) references Simple (id_)
69 Query SET autocommit=0
69 Query rollback
69 Quit

SQL sent to server by SchemaExport:

050309 15:48:22 70 Connect root@localhost on test
70 Init DB test
70 Query select round('inf'), round('-inf'), round('nan')
70 Query SHOW VARIABLES
70 Query SET autocommit=1
70 Query SET autocommit=0
70 Query commit
70 Query SET autocommit=1
70 Query alter table Simple drop foreign key FK939D1DD26527F10
70 Query drop table if exists Simple
70 Query create table Simple (id_ bigint not null, name varchar(255), address varchar(255), count_ integer not null unique, date_ datetime, pay float, other bigint, primary key (id_))
70 Query create index test_idx on Simple (name)
70 Query alter table Simple add index FK939D1DD26527F10 (other), add constraint FK939D1DD26527F10 foreign key (other) references Simple (id_)
70 Quit

Environment

Hibernate version: 2.1.8, MySQL version: 4.0.20, MySQL driver: mysql-connector-java-3.0.10-stable (also verified with 3.0.16 and 3.1.7)

Assignee

Unassigned

Reporter

Keith Wall

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Affects versions

Priority

Minor
Configure