首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

spring data 四 mongoDB 自动创建复合索引

2013-03-01 
spring data 4 mongoDB自动创建复合索引spring data 4 mongodb 在domain上添加annation,自动创建复合索引

spring data 4 mongoDB 自动创建复合索引
spring data 4 mongodb 在domain上添加annation,自动创建复合索引时需要使用CompoundIndexes。

例如:

@CompoundIndex(name = "shop_index", def = "{platform : 1, shopId : 1}")
程序也不会有编译错误或者执行错误,但是spring data不会建立任何索引,
下面这样写才会启动时自动建立复合索引。
@CompoundIndexes({
@CompoundIndex(name = "shop_index", def = "{platform : 1, shopId : 1}")
})

热点排行