Hi Hibernate community,
I’d like to propose a new feature for Hibernate ORM: adding support for ULID (Universally Unique Lexicographically Sortable Identifier) as an identifier generation strategy.
Currently, Hibernate supports standard strategies such as AUTO, IDENTITY, SEQUENCE, TABLE, and also has extended support for UUID.
ULID provides several advantages over UUID for certain use cases:
- Lexicographically sortable: can preserve creation order in the database
- URL-safe string representation
- Collision-free across distributed systems
- Useful for sharding or multi-region setups
Proposed usage example:
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.ULID)
private String id;
// other fields...
}
Implementation approach could involve:
- Creating a
ULIDIdentifierGeneratorimplementingorg.hibernate.id.IdentifierGenerator - Registering a new generation strategy in Hibernate similar to UUID
- Adding relevant tests and documentation
I believe this feature would benefit developers needing globally unique, sortable, URL-safe IDs while keeping the convenience of @GeneratedValue.
I would be happy to contribute the implementation and submit a PR once the community supports this idea.
Thank you for considering this feature request!