Hi Vadim, thanks for opening this issue!
Atm. Hibernate OGM does not yet explicitly support sharded collections in MongoDB, we also don't have any specific tests for that. But it's definitely something we should add. An annotation (or more generically, an "option" which may be given via an annotation or via the fluent configuration API) for specifying the shard key of an entity seems very reasonable. It would also allow to enable sharding of the collection based on that key during schema initialization. Would you be interested in helping out with implementing such feature?
Btw. as a workaround (whether it works or not may depend on your id generation strategy) you may try to use a compound id for your entity which comprises the actual id as well as your shard key. This should add the shard key to the "where clause" of updates.
|