How to do multiple column unique-constraint in ormlite ( SQLite )
How about using
@DatabaseField (uniqueCombo = true) String myField;
annotation instead - is it a matter of the uniqueIndexName being faster when accessing items in the table?
Edit:
As @Ready4Android pointed out, we've since added in version 4.20 support for uniqueCombo
annotation field. Here are the docs:
There should be no performance differences between using this mechanism versus the uniqueIndexName
mentioned below.
Yes. You can't do this with the unique=true
tag but you can with a unique index.
@DatabaseField(uniqueIndexName = "unique_store_group_and_item_ids")int store_group_id;@DatabaseField(uniqueIndexName = "unique_store_group_and_item_ids")int store_item_id;
This will create an index to accomplish the unique-ness but I suspect that the unique=true has a hidden index anyway. See the docs:
I will look into allowing multiple unique fields. May not be supported by all database types.