Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用hibernate JPA 2以二进制形式存储uuid_Java_Hibernate_Binary_Jpa 2.0_Uuid - Fatal编程技术网

Java 如何使用hibernate JPA 2以二进制形式存储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

我有一个关于通过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, nullable = false)
public final UUID getId() {
    return id;
}

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

二进制UUID的类型是
UUID binary
。您必须使用Hibernate 3.6才能使其正常工作

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