@Entity
public class FruitStore {
@Id
private Long storeId;
@ElementCollection
private Set<Fruit> fruits;
}
Of course, the Fruit
class is marked @Embeddable
.
In the database (postgresql to be exact, although it shouldn't matter), there is a table created called fruitstore_fruits
. It grows huge, and queries on it become very very slow. I have manually modified the database, such that the fruitstore_fruits
table indexes on the FruitStore
id
column. Happily, this dramatically improves performance. I want this to be done automatically.
The question is, how can I annotate my code to get Hibernate to automatically index the fruitstore_fruits on the FruitStore
id
column?
EDIT: This Hibernate bug has removed lots of hope. I think what I want is simply not supported right now. Which is kinda sad, because the feature isn't that exotic (indexing a element collection with a foreign column). However, I'd love to be proven wrong here.
Take a look for example of how it could be done:
@CollectionTable(indexes = {@Index(columnList = "solution_version_training_session_id")})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With