如何用ormlite编写按日期查询分组?

时间:2018-07-17 16:49:24

标签: android database orm ormlite

我使用ormlite在android应用程序上处理数据库。 我用日期和计数列创建新表。 日期请遵循以下格式:“ yyyy-MM-dd HH:mm”

我想每天计数,怎么办? (这意味着我们应该按日期查询编写分组,但该怎么做?)

@DatabaseTable(tableName = "addict_event")
public class AddictEvent implements Serializable {
    public final static String ID_ADDICT_COLUMN_NAME = "id";
    public final static String COUNT_ADDICT_COLUMN_NAME = "count";
    public final static String LABEL_ADDICT_COLUMN_NAME = "addict_label";
    public final static String DATE_ADDICT_COLUMN_NAME = "date";

    @DatabaseField(id = true, generatedId = true, columnName = ID_ADDICT_COLUMN_NAME, canBeNull = false)
    private long id;

    @DatabaseField(columnName = COUNT_ADDICT_COLUMN_NAME)
    private int count;

    @DatabaseField(foreign = true, columnName = LABEL_ADDICT_COLUMN_NAME)
    private AddictLabel addictLabel;

    @DatabaseField(dataType = DataType.DATE_STRING, format = "yyyy-MM-dd HH:mm", columnName = DATE_ADDICT_COLUMN_NAME)
    private Date dateTime;
}

0 个答案:

没有答案