[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3721) MySql creates multiple indicies when "unique" specified on both column specification and constraint

Hugh Daschbach (JIRA) noreply at atlassian.com
Mon Jan 19 19:48:39 EST 2009


MySql creates multiple indicies when "unique" specified on both column specification and constraint
---------------------------------------------------------------------------------------------------

                 Key: HHH-3721
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3721
             Project: Hibernate Core
          Issue Type: Improvement
          Components: core
    Affects Versions: 3.2.0.ga
         Environment: MySql 5.0, hibernate-3.2 compiled from SVN revision 12635.
            Reporter: Hugh Daschbach
            Priority: Minor
         Attachments: hibernate-3.2.patch

MySql seems to duplicate indexes when "unique" is specified both on the column specification as a constraint.

For example:
create table groups (
    id int unsigned not null unique auto_increment,
    groupname varchar(30) unique not null,
    primary key (id),
    unique (groupname)
) engine = InnoDB;


show index from groups;

+--------+------------+-------------+--------------+-------------+- ...
| Table  | Non_unique | Key_name    | Seq_in_index | Column_name | 
+--------+------------+-------------+--------------+-------------+- ...
| groups |          0 | PRIMARY     |            1 | id          |  ...
| groups |          0 | id          |            1 | id          |  ...
| groups |          0 | groupname   |            1 | groupname   |  ...
| groups |          0 | groupname_2 |            1 | groupname   |  ...
+--------+------------+-------------+--------------+-------------+- ...

Note four indexes instead of two.

The attached patch suppresses the "unique" qualifier on the column specification emitted by hbm2ddl.  It may be better to apply this to MySqlDialect instead of MySqlInnoDBDialect.  Or I may be mistaken altogether.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list