I want to make use of ORMLite capabilities, but I encountered an small issue which I do not know how to overcome.
I have to setup an table with composite key. These keys should also be setup as an foreign key which points to another table.
Table1
@DatabaseField(columnName = "column1", uniqueCombo = true, foreign = true, foreignColumnName = Table2.columnOne)
long columnOne;
@DatabaseField(columnName = "column2", uniqueCombo = true, foreign = true, foreignColumnName = Table2.columnOne)
long columnTwo;
@DatabaseField(columnName = POSITION)
int mPosition;
Table2
@DatabaseField(columnName = "column1", id = true)
long columnOne;
How can I set columnTwo to be also used as an foreign key to another table? Is this even possible with ORMLite?
Thank you.
LE:
I have managed to achieve this with the following manual SQL statement:
CREATE TABLE table1(
column1 BIGINT not null,
column2 BIGINT not null,
position INTEGER,
FOREIGN KEY (column1) REFERENCES table2(column1),
FOREIGN KEY (column2) REFERENCES table2(column1),
PRIMARY KEY(column1, column2)
)
Is it possible to do something similar using ORMLite for Android?
Aucun commentaire:
Enregistrer un commentaire