pierre tautou
pierre tautou

Reputation: 817

How to store uuid in binary form using hibernate JPA 2

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.

Upvotes: 7

Views: 8580

Answers (1)

Adrian Cox
Adrian Cox

Reputation: 6334

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.

Upvotes: 7

Related Questions