正确使用Column.ForeignKeyAction.CASCADE

时间:2014-06-04 11:03:45

标签: android activeandroid

如果我有这样的关系,我想要的是每当我在delete()上致电User时,vehicle字段也会被删除。

@Table (name = "Users")
public class User extends Model {
    @Column(name = "Name", unique = true, onUniqueConflict = Column.ConflictAction.REPLACE) name;
    @Column(name = "Vehicle") Vehicle vehicle;
}

@Table (name = "Vehicles")
public class Vehicle extends Model {
    @Column(name = "Name", unique = true, onUniqueConflict = Column.ConflictAction.REPLACE) name;
}

我认为这可以通过在onDelete = Column.ForeignKeyAction.CASCADE上使用Vehicle.name来实现,但我不太确定,所以我会继续问问。

0 个答案:

没有答案