How to store uuid in binary form using hibernate JPA 2

旧巷老猫 提交于 2019-12-23 12:09:49

问题


I have a question about string uuid in database in binary form through hibernate persistence (JPA2). I'm using now this code:

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;
}

This work fine, but I must store it in binary form. Don't ask me why, but I must.


回答1:


The type for binary UUID is uuid-binary. You must have Hibernate 3.6 for this to work.

For many more details and pitfalls, see the answers to this question.



来源:https://stackoverflow.com/questions/6522420/how-to-store-uuid-in-binary-form-using-hibernate-jpa-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!