Active Android onDelete和onDelete [英] Active Android onDelete and onDelete

查看:91
本文介绍了Active Android onDelete和onDelete的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用活动Android 。试图了解更多信息,特别是关于表项属性-smth,例如ForeignKeyAction。

I use Active Android in my project. Trying to learn more about it, especial about table items properties -smth like ForeignKeyAction.

我希望我的模型只删除自身(如果发生删除操作),而不希望删除删除它的孩子。
我找到的代码-

I want for my model to delete only itself, if delete action is occured, and not to delete it's children. Code I found -

@Column(name = "Category", onUpdate = ForeignKeyAction.CASCADE, onDelete = ForeignKeyAction.CASCADE)
public Category category;

但我不知道是什么标志着什么财产-其中很多-
表单文档

But I do not know what flag answeirs for what property - there are plenty of them - form docs

public enum ForeignKeyAction {
    SET_NULL, SET_DEFAULT, CASCADE, RESTRICT, NO_ACTION
}

任何人都可以发布指向详细说明的链接,或解释这些内容。
PS我浏览了许多网站,其中包括 https://guides.codepath.com/android / ActiveAndroid-Guide
https://github.com/ pardom / ActiveAndroid / wiki /入门
不在这里指我,对此问题没有任何解释。

Can anyone post a link to detailed explanation, or explain this stuff. PS I explored lots of sites, inluding https://guides.codepath.com/android/ActiveAndroid-Guide and https://github.com/pardom/ActiveAndroid/wiki/Getting-started do not refer me there, there is no explanation on this question.

另外,还有什么属性,例如onDelete,我可以设置到模型字段吗?

Also, what other properties, like onDelete i can set to my model fields?

推荐答案

这些不是活动android的属性,而是SQL。我猜想活跃的Android会利用Android中的SQLite数据库。在这种情况下,它们的含义如下:

These aren't properties of active android, but rather SQL. I'm guessing that active android utilizes the SQLite database in Android. If that's the case, here are their meanings:

无操作:配置无操作意味着:修改父键时

NO ACTION: Configuring "NO ACTION" means just that: when a parent key is modified or deleted from the database, no special action is taken.

RESTRICT : RESTRICT操作表示禁止删除该应用程序( (对于ON DELETE RESTRICT)或修改(对于ON UPDATE RESTRICT)父键(如果存在一个或多个映射到它的子键)。 RESTRICT动作和常规外键约束执行的效果之间的区别在于,RESTRICT动作处理在字段更新后立即进行-而不是像立即约束那样在当前语句的末尾或结尾处进行与延迟约束相同的当前交易额。即使推迟了附加的外键约束,如果删除或修改了具有相关子键的父键,配置RESTRICT操作也会导致SQLite立即返回错误。

RESTRICT: The "RESTRICT" action means that the application is prohibited from deleting (for ON DELETE RESTRICT) or modifying (for ON UPDATE RESTRICT) a parent key when there exists one or more child keys mapped to it. The difference between the effect of a RESTRICT action and normal foreign key constraint enforcement is that the RESTRICT action processing happens as soon as the field is updated - not at the end of the current statement as it would with an immediate constraint, or at the end of the current transaction as it would with a deferred constraint. Even if the foreign key constraint it is attached to is deferred, configuring a RESTRICT action causes SQLite to return an error immediately if a parent key with dependent child keys is deleted or modified.

SET NULL :如果配置的操作为 SET NULL,则在删除父键(对于ON DELETE SET NULL)或修改父键(对于ON UPDATE SET NULL)时,子键列子表中映射到父键的所有行中的所有行都设置为包含SQL NULL值。

SET NULL: If the configured action is "SET NULL", then when a parent key is deleted (for ON DELETE SET NULL) or modified (for ON UPDATE SET NULL), the child key columns of all rows in the child table that mapped to the parent key are set to contain SQL NULL values.

SET DEFAULT : SET DEFAULT除了每个子键列设置为包含列的默认值而不是NULL之外,操作与 SET NULL相似。有关如何将默认值分配给表列的详细信息,请参见CREATE TABLE文档。

SET DEFAULT: The "SET DEFAULT" actions are similar to "SET NULL", except that each of the child key columns is set to contain the columns default value instead of NULL. Refer to the CREATE TABLE documentation for details on how default values are assigned to table columns.

CASCADE : CASCADE操作传播删除操作或将父键上的操作更新为每个从属子键。对于 ON DELETE CASCADE操作,这意味着子表中与已删除的父行关联的每一行也将被删除。对于 ON UPDATE CASCADE操作,这意味着修改存储在每个从属子键中的值以匹配新的父键值。

CASCADE: A "CASCADE" action propagates the delete or update operation on the parent key to each dependent child key. For an "ON DELETE CASCADE" action, this means that each row in the child table that was associated with the deleted parent row is also deleted. For an "ON UPDATE CASCADE" action, it means that the values stored in each dependent child key are modified to match the new parent key values.

此外,这是我在其中找到此信息的链接。您还可以查看常规 SQLite文档

In addition, here's a link where I found this information. You can also check out the general SQLite documentation.

这篇关于Active Android onDelete和onDelete的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆