In today’s modern SAAS applications the database usually contains composite key as the primary key as one of the strategies of multitenancy is to have a tenant column in all tables.
Hence the natural way of choosing a primary key is to create a composite key consisting of [tenant column] + [id] column.
Choosing the ID column as autogenerated is a preferable and safe way to make sure the primary keys are generated at the database level.
In this scenario, the Hibernate Fails however we can achieve this feature in other ORM (EclipseLink etc.) with some custom defined annotations.
Here is a link with an example of this issue.
Now, When we evaluate what is the best ORM to choose for the product, Every time I conclude with hibernate as it checks all boxes, But just because of this deficiency we have to go with some other ORMs.
I’ve found some older links about this issue as well (https://forum.hibernate.org/viewtopic.php?f=1&t=1006818),
It’s pretty strange why hibernate community has not addressed this yet.
Hoping this feature would land in Hibernate 6 or in future…