Hibernate JPA 的索引的使用
在Hibernate中Model中一个对象关联的对象相当多是必须使用索引,如果多个表关联更要使用关联,否则效率相等的低下,例如在项目中酒店的查询中大约有几千条数据但是查询就需要5分钟以上,实在是一个严重的效率瓶颈,采用的方案,在集合等地方添加相应的索引,加快搜索效率。
如下:
针对重复几率比较大的使用索引:
/*** 现付含早frontBreakfast(旧),周一~周日*/@CollectionOfElements@JoinTable(name = "T_RTP_CASH_BT")@Type(type = "breakfastTypeEnum")@IndexColumn(name = "cashBreakfastTypes_pos")private List<BreakfastType> cashBreakfastTypes = getDefaultBreakfastType();
还有各种各种情况必须添加相应的索引。