我有一个关于使用Hibernate Persistence(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;
}
这个工作很好,但我必须以二进制形式存储它。不要问我为什么,但我必须这样做。