Hi!
I have an entity class with an @EmbeddedId (field1 int and field2 int). Based on the manual, I understand that making a query just on entity.id.field1 is efficient. Of course, making a query containing the whole EmbeddedId is the ideal case, and I use it, but I need more use cases.
My question is: what about making a query just on entity.id.field2? I suppose it will not be an efficient query, because all database entries have to be checked. My assumption is based on the fact that entity.id.field1 and entity.id.field2 form a composite index together, in the order in which they were declared.
In this case, can I just declare an additional index on entitiy.id.field2 in the entity class as @Indices({@Index(members = {"id.field2"})}) or do I have to duplicate entity.id.field2 into entity.field2 and then set an index on it?
I am really interested in this question. Thank you in advance.