Requery for Android会自动生成类吗?

时间:2018-04-30 09:08:48

标签: android android-database

我有几个Model对象(CateogryModel,MenuModel,OrderModel等)。我现在正在尝试实现本地数据库,并决定使用Requery。

在他们的文档中,他们提到:

  getter,setters,equals& hashCode自动生成Person.java

所以,让我们假设我已经拥有以下内容的Person.java:

private class Person
{
    int id;
    String name;

    //getter setter
}

我将其更改为:

@Entity
abstract class Person
{
    @Key @Generated
    int id;

    @Index("name")
    String name;
}

会发生什么?我的吸气者和二传手会去哪儿?在构建应用程序时,requery会生成一个新类吗?

1 个答案:

答案 0 :(得分:1)

构建项目时,Requery将在app / build / generated文件夹中生成PersonEntity类,其包名与Person类相同。

来自API文档:

 /**
 * @return the desired Entity name for the type. This class will be generated by the processor
 * in the same package as the type the annotation is placed on. This name is also used as the
 * table name unless a {@link Table} attribute is specified with a different name.
 * Defaults to empty, the processor will remove "Abstract" prefix from the class name if it
 * exists.
 */