Creating table Order with Foreign Key not possible
I want to create a table called Order with a foreign key like this
@Column(columnType = Column.FOREIGN_KEY, references = {@ForeignKeyReference(columnName = "orderId", columnType = Integer.class, foreignColumnName = "id")}) public Order order;
But I get the error when I try to create the table
Caused by: android.database.sqlite.SQLiteException: near "Order": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTSOrderItem(idINTEGER PRIMARY KEY AUTOINCREMENT,orderIdINTEGER DEFAULT 0,productItemIdINTEGER DEFAULT 0,nameTEXT,sortOrderINTEGER DEFAULT 0, FOREIGN KEY(orderId) REFERENCES Order (id) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(productItemId) REFERENCES ProductItem (id) ON UPDATE NO ACTION ON DELETE NO ACTION );
It seems that order is a reserved keywords.