According to the documentation, hibernate 3.6 should have support for the java.util.UUID type. But when I map it like:
@Id protected UUID uuid;
Using Hibernate 4 and MySQL 5.5 with an InnoDB table, I was able to store a UUID column as BINARY(16) as-is (no configuration or custom type required). I am not using this as the entity ID and am creating the value manually using UUID.randomUUID().
@Entity
@Table(name = "post")
public class PostModel implements Serializable
{
...
@Column(name = "uuid", nullable = false, updatable = false)
private UUID uuid;
...
}
> desc post;
+----------------+---------------+------+-----+---------------------+
| Field | Type | Null | Key | Default |
+----------------+---------------+------+-----+---------------------+
| ... | | | | |
| uuid | binary(16) | YES | UNI | NULL |
| ... | | | | |
+----------------+---------------+------+-----+---------------------+