@Entity
public class FruitStore {
@Id
private Long storeId;
@ElementCollection
private Set<Fruit> fruits;
}
Run Code Online (Sandbox Code Playgroud)
当然,Fruit班级已经标记@Embeddable.
在数据库中(确切地说postgresql,虽然它应该无关紧要),有一个创建的表叫做fruitstore_fruits.它变得越来越大,对它的查询变得非常缓慢.我已手动修改了数据库,fruitstore_fruits使FruitStore id列上的表索引.令人高兴的是,这大大提高了性能.我希望自动完成此操作.
问题是,我如何注释我的代码以使Hibernate自动索引FruitStore id列上的fruitstore_fruits ?
编辑: 这个Hibernate错误消除了很多希望.我认为我想要的东西现在根本得不到支持.这有点难过,因为该功能不是那种奇特(用外来列索引元素集合).不过,我喜欢在这里证明是错误的.