【发布时间】:2019-03-05 10:37:20
【问题描述】:
我正在将 Web 应用程序从 Windows 机器部署到运行 MariaDB 10.1.26 的 debian 服务器(一切都在开发机器上运行)。问题是一些 DDL 没有执行。有问题的类是用户类:
@Entity
public class User {
@Id
@Type(type = "uuid-char")
@GeneratedValue(generator = "UUID")
@GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
private UUID id;
private String firstname;
private String lastname;
@Column(unique = true)
private String emailAddress;
private String passwordHash;
}
我使用的hibernate属性是:
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
我得到的错误是:
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
我认为这是因为 UUID 键而发生的。我该如何解决这个问题?
【问题讨论】:
标签: java mysql hibernate mariadb