ORMLite - 具有相同列的多个索引

时间:2012-08-23 14:18:11

标签: java android ormlite

在ORMLite中,是否可以让同一列参与多个索引? @DatabaseField(index=...)注释似乎每个字段只允许一个索引。

例如,我可能有一个班级:

public class PhoneCall{
    @DatabaseField
    public Date timestamp;
    @DatabaseField
    public String from;
    @DatabaseField
    public String to;
}

我的查询总是首先按时间戳,然后按'从'或'到'来完成。

在这种情况下,我需要两个组合索引:

  • index1 :(时间戳,来自)
  • index2 :(时间戳,到)

谢谢!

1 个答案:

答案 0 :(得分:0)

来自DatabaseField

的javadoc
    /**
     * Set this to be a string (default none) to have the database add an index for 
     * this field with this name. You do not need to specify the {@link #index()} 
     * boolean as well. To index multiple fields together in one index, each of
     * the fields should have the same indexName value.
     */
    String indexName() default "";

但我不知道如何在两个不同的索引中使用相同的字段。

相关问题