【问题标题】:How to store uuid in binary form using hibernate JPA 2如何使用休眠 JPA 2 以二进制形式存储 uuid
【发布时间】:2011-06-29 14:33:27
【问题描述】:

我有一个关于通过休眠持久性 (JPA2) 以二进制形式存储在数据库中的字符串 uuid 的问题。我现在正在使用这段代码:

private UUID id;

@Id
@Type(type="uuid-char")
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
@Column(length = 32, unique = true, nullable = false)
public final UUID getId() {
    return id;
}

这很好,但我必须以二进制形式存储它。不要问我为什么,但我必须。

【问题讨论】:

    标签: java hibernate binary jpa-2.0 uuid


    【解决方案1】:

    二进制 UUID 的类型是 uuid-binary。您必须安装 Hibernate 3.6 才能正常工作。

    有关更多详细信息和陷阱,请参阅this question 的答案。

    【讨论】:

      猜你喜欢
      • 2011-10-01
      • 2017-09-22
      • 1970-01-01
      • 2014-08-08
      • 1970-01-01
      • 2022-01-12
      • 1970-01-01
      • 2020-10-25
      • 2011-10-26
      相关资源
      最近更新 更多