Hibernate 5.4 UUID生成失败,Mysql 5.7出现奇数错误

时间:2020-08-15 19:39:55

标签: mysql hibernate jpa

我们有这些休眠设置

    properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL57Dialect");
    properties.setProperty("hibernate.hbm2ddl.auto", "update");
    properties.setProperty("hibernate.show_sql", "false");
    properties.setProperty("hibernate.format_sql", "false");
    properties.setProperty("hibernate.transaction.flush_before_completion", "true");
    properties.setProperty("hibernate.jdbc.batch_size", "50");
    properties.setProperty("hibernate.order_inserts", "true");
    properties.setProperty("hibernate.order_updates", "true");
    properties.setProperty("hibernate.jdbc.batch_versioned_data", "true");

我们有这个主键

@Id
@GeneratedValue
//Do we need to define the type??
@Column(columnDefinition = "BINARY(16)")
private UUID id;

我们得到这个错误

Caused by: java.lang.IllegalArgumentException: Expecting 8 byte values to construct a long

我们这样做是为了进行批处理,因此由于IDENTITY生成不好,因此在Mysql中可以进行批处理。和顺序使我们拥有所有这些额外的表(有点烦人)。

有什么想法不能解决上述问题吗?

0 个答案:

没有答案