@GeneratedValue
If we have a UUID
that is not the @Id we
can add @GeneratedValue
and
then Ebean will assign a appropriate UUID generator to it.
/** The Id property using DB Identity or Sequence */
@Id @GeneratedValue
private long id;
/** Alternate unique UUID property */
@GeneratedValue @Column(unique = true)
private UUID uid;
Native storage
UUID has native support in the following database platforms:
- H2
- Postgres
- SQL Server 17
When using these database platforms UUID is stored in a native manor.
Binary storage
Stored as BINARY(16), has the option of storing in optimised manor meaning the order of bytes is changed to provide a better distribution in index.
Varchar storage
Stored as VARCHAR(40).
DatabaseConfig.setDbUuid()
When the database platform does not support UUID natively we can configure the
storage option via DatabaseConfig.setDbUuid(...)