Я пытаюсь получить контроль над фактическим именованием индексов в базе данных из hibernate, но безрезультатно с MySQL57Dialect на mysql 5.7.29. Ранее у меня был код, подобный ответу в этом посте
Автоматически ли Hibernate создает индекс?
На самом деле, вот соответствующие аннотации CustomerDbo. java file ..
@Entity
@Table(name="CUSTOMERS",
indexes={
@Index(name="tokenIndex", columnList="token", unique=true),
@Index(name="emailIndex", columnList="email", unique=true)
}
)
@NamedQueries({
@NamedQuery(name = "findAllCustomers", query = "select u from CustomerDbo as u"),
@NamedQuery(name = "findByToken", query = "select c from CustomerDbo as c left join fetch c.services o where c.token=:token")
})
public class CustomerDbo {
Вот два поля, которые являются уникальными и которые, конечно, заканчивают тем, что создают индекс ..
@Column(unique = true)
private String token;
@Column(unique = true)
private String email;
Вот показ индексов из mysql после удаления всех таблиц и загрузки моего приложения гибернации, которое создает все таблицы и индексы ..
mysql> show index from CUSTOMERS;
+-----------+------------+------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------+------------+------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| customers | 0 | PRIMARY | 1 | id | A | 2 | NULL | NULL | | BTREE | | |
| customers | 0 | UK_rm2i6cehierocrpf810l2jl1v | 1 | email | A | 1 | NULL | NULL | YES | BTREE | | |
| customers | 0 | UK_b16n4n7r0vtvgbvijc2os3aug | 1 | token | A | 2 | NULL | NULL | YES | BTREE | | |
+-----------+------------+------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)
Есть ли способ исправить это, чтобы у индексов были имена, которые я им дал? (Это все работало в postgres в один прекрасный момент просто отлично.)
спасибо, Дин