I tried to use the code below to ensure referential integrity in my database, but seems not to be working with GreenDao. I can still delete all the records. On the other hand, when I try to delete in Sqlitemanager, the trigger is raised and delete operation fails.
DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, Common.DBNAME, null)
{
@Override
public void onCreate(SQLiteDatabase db) {
super.onCreate(db);
db.execSQL("CREATE TRIGGER grupe_artikli BEFORE DELETE ON groups "+
"FOR EACH ROW BEGIN "+
"SELECT CASE " +
"WHEN ((SELECT id_group FROM products WHERE id_group = OLD._id) IS NOT NULL) "+
"THEN RAISE(ABORT, 'error') "+
"END; END;");
DaoSession session = new DaoMaster(db).newSession();
}
Does GreenDao support triggers, or is there another method to maintain database referential integrity?