Yuri Misyac Yuri Misyac - 1 year ago 155
Android Question

DBFlow model without primary key

When i try write model without primary key i get

Error:Table SCHEDULE_ITEM needs to define at least one primary key

Is posible write dbflow model without @PrimaryKey field ?


@Table(databaseName = AppDatabase.NAME, tableName = "SCHEDULE_ITEM")
public class ScheduleItem extends BaseModel implements Serializable{

@Column(name = "ITEM_TYPE")
private Integer itemType;
@Column(name = "INTERNAL_ID")
private String internalId;
@Column(name = "DATE")
private String date;
@Column(name = "TIME")
private String time;

//geters and seters

Answer Source

Nope, I got weird errors recently as below, said it couldn't find those "$Table" classes, but actually they had been built and in there.

I commented and uncommented every new java files. And eventually I found that's because there is no "@PrimaryKey" in one model class of DBFlow.

So, you have to define the bloody "@PrimaryKey" for your DBFlow model classes( and don't forget to extends BaseModel as well). PS: DBFlow Version 3.0.0-beta

/Users/XXX/code_projects/###/src/main/java/com/XXXXX.java:9: error: cannot find symbol
import com.XXX.databasemodel.XXX$Table
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download