我们有以下实体关系,其中用户属于特定组织。我的查询看起来像“select * from User where org=:org”或“select * from User where org=:org and type=:type”
我在 User 类上有单独的索引。第一个查询会很好,因为外键元素上有索引。第二个查询是否要求在 org 和 type 列上使用多列索引。如果是这样,我应该如何注释来创建一个这样的索引。
@Entity
class User {
...
@ManyToOne
@ForeignKey
@Index
Organization org;
@Index
Type type;
...
}
Run Code Online (Sandbox Code Playgroud)