In terms of enhancement @Id properties are treated differently in that they never invoke lazy loading.

Generated value

When you annotate a property with @Id Ebean will automatically assign an appropriate Id generator if the type is a number type or UUID type.

That is, with Ebean it is effectively redundant to also add the @GeneratedValue annotation.

long id;

// ... is effectively the same as

@Id @GeneratedValue
long id;


If the @Id type is UUID then Ebean will automatically assign an appropriate Id generator to that property.

// an appropriate UUID based Id generator
// is automatically assigned
UUID id;

Database platform

All the supported databases use either Identity or Sequences (or allow both) and Ebean will choose the appropriate Id generation strategy based on the database platform.

H2Identity (also supports sequences)
PostgresIdentity (as serial, also supports sequences)
OracleSequences (also supports Identity)
DB2Identity (also supports sequences)
SQL ServerIdentity

Custom Id Generator

There is support for registering and using a custom Id generator.

1. Implement io.ebean.config.IdGenerator

public class ModUuidGenerator implements IdGenerator {

  public Object nextValue() {
    return ModUUID.newShortId();

  public String getName() {
    return "shortUid";

2. Register with ServerConfig

We register the IdGenerator with ServerConfig by using addClass() or add(IdGenerator idGenerator) or setIdGenerators(List idGenerators).

Note that if you are using classpath scanning to find entity beans that this will also automatically find implementations of IdGenerator and automatically register them so in this case you don't need to register the IdGenerator manually with ServerConfig.

3. @GeneratedValue

We can then tell Ebean to use our custom IdGenerator by using the @GeneratedValue with the generator being the name of our custom IdGenerator.

@Id @GeneratedValue(generator = "shortUid")
String id;