When I have many entities and I want to use custom id generators (for example snowflake) with different sequences for each entity, should I write the corresponding generator in each entity or write all the id generators in one configuration class or one configuration class for each entity?
I don't think it can be coded in each entity, because it can only build one in each entity. But what if I use a static idWorker
? (here idWorker
is a property in the entity)
The Spring has examples, but they are too simple.