Java 如何使用hibernate JPA 2以二进制形式存储uuid
我有一个关于通过hibernate持久化(JPA2)以二进制形式存在于数据库中的字符串uuid的问题。我现在使用的代码是:Java 如何使用hibernate JPA 2以二进制形式存储uuid,java,hibernate,binary,jpa-2.0,uuid,Java,Hibernate,Binary,Jpa 2.0,Uuid,我有一个关于通过hibernate持久化(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, null
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;
}
这项工作很好,但我必须以二进制形式存储它。不要问我为什么,但我必须问。二进制UUID的类型是
UUID binary
。您必须使用Hibernate 3.6才能使其正常工作
有关更多详细信息和陷阱,请参阅的答案