0 Replies Latest reply on Mar 20, 2006 6:57 PM by Dave Chen

    index automatically generatedy Hibernate?

    Dave Chen Master

      I am using Jboss 4.0.3SP1.

      I have a Employee table.(id, name, addrId).

      Employee {
      ...
      @OneToOne
      @JoinColumn(name="addrId")
      Address getAddress() {...}

      String getName() {...}
      }

      I did not use @index on any properties.

      After deploy,

      mysql > show index from employee;

      +------------+------------+---------------------------+--------------+---
      | Table Non_unique | Key_name | Column_name
      +------------+------------+---------------------------+--------------+---
      | employee| 0 | PRIMARY | id
      | employee| 0 | name | name
      | employee| 0 | addrId | addrId
      | employee| 1 | FKE5C254025FFF52BB | addrId

      It seems that Hibernate has created 4 indexes.
      Why create two indexes for addrId?
      Is it useful to create index for addrId?


      If I add index on name,

      @Index(name="employee_name_idx")
      String getName() {...}

      The index on name will be created, ignoring existing index (on name).
      I am confused. Please help me understand. It would be very nice. Thanks!