4

I have a persistent class that extends a parent where some of its fields are defined. With Spring Data Mongo, I can use the @Indexed annotation on persistent fields to create index on the corresponding Collection. However, in the case of inherited fields, I can only access them through the parent class. I could probably put the annotation there but I don't want to create index for a every Collection extending the parent class. Can I potentially use @CompoundIndex (with single value) to work around this?

1 Answer 1

4

After doing some local testing, I found out that, yes, I can use @CompoundIndex to workaround this issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.