cub*_*buk 3 mongodb morphia mongodb-java
我正在使用morphia github 1.2.2版.我知道如何在morphia实体上的一个字段上注释索引,但有没有办法在两个字段的组合上注释索引.例如,如果我想在字段a和b上有一个复合索引,那么下一个类的注释是什么.
@Entity
public class TestClass
{
@Property("a")
private int fieldA;
@Property("b")
private int fieldB;
//how to annotate index of compound key fieldA and fieldB using morphia index annotation?
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
@Entity
@Indexes(@Index(name = "aAndB", value = "a, b"))
public class TestClass
{
@Property("a")
private int fieldA;
@Property("b")
private int fieldB;
//how to annotate index of compound key fieldA and fieldB using morphia index annotation?
}
Run Code Online (Sandbox Code Playgroud)
为索引指定名称是可选的.您还可以使复合索引唯一.
| 归档时间: |
|
| 查看次数: |
4349 次 |
| 最近记录: |