I\'m using my uuid as following:
@Id
@GeneratedValue(generator = \"uuid\")
@GenericGenerator(name = \"uuid\", strategy = \"uuid\")
@Column(name = \"uuid\", u
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid")
@Column(name = "UUID_ID")
public String getId(){
return id;
}
This is the proper way to use annotation for uuid generators in Hibernate 5.0.11.FINAL.
Note: IT is deprecated.
With current 5.4.2 Hibernate version,
if you want a Human-Readable varchar(36) field in the database table,
but also a Serializable UUID data type in your Java Class,
you can use @Type(type = "uuid-char")
at the same time you declare your field member with java.util.UUID
type.
Note that @Column(length = 36)
is important to reduce from 255 to 36 the field length in MySQL.
Note that with PostgreSQL you should use @Type(type = "pg-uuid")
instead.
import org.hibernate.annotations.Type
import java.util.UUID
import javax.persistence.Column
import javax.persistence.GeneratedValue
import javax.persistence.Id
@Id @GeneratedValue
@Type(type = "uuid-char") @Column(length = 36)
private UUID id;