当前位置:网站首页>Attribute keywords ondelete, private, readonly, required
Attribute keywords ondelete, private, readonly, required
2022-07-07 14:30:00 【User 7741497】
The first 105 Chapter Attribute keyword - OnDelete
Specify the action to be taken in the current table when deleting related objects . This keyword is only applicable to the cardinality Cardinality
Designated as “ Father ” or “ One ” Relationship properties of . Its use is invalid in all other contexts .
usage
To specify the action to be taken in the current table when deleting related objects , Please use the following syntax :
Relationship relname As classname [ Cardinality = cardinality, Inverse = inverse, OnDelete = ondelete ];
among ondelete
Is one of the following values . In this discussion , Related records are records or objects belonging to the other party of the relationship , A reference record is a record or object of the party to the relationship .
cascade
cascade — When deleting related records , The reference records in this table will also be deleted .noaction
No operation — When trying to delete related records , Attempts will fail .setdefault
— When deleting related records , The reference records in this table will be set to their default values .setnull
— When deleting related records , The reference records in this table will be set tonull
.
Detailed explanation
This keyword defines the reference operation that occurs when a record is deleted at the other end of the relationship .
Default
If you ignore this keyword , be :
- about
Cardinality
Cardinality is the parent relationship ,OnDelete
It's cascading . in other words , When deleting the parent record , By default , The associated child record will be deleted . - For cardinality 1 The relationship between ,
OnDelete
bynoaction
. in other words , When trying to delete “ One ” When recording , By default , If another table has any records pointing to it , Try and fail .
Example
Class MyApp.Employee Extends %Persistent {
...
Relationship Employer As MyApp.Company [ Cardinality = one, Inverse = Employees, OnDelete = cascade ];
}
This example shows the one to many relationship between the company and employees . As shown in the figure ,Cardinality
It means that the company is related “one”
, and OnDelete
Indicates the impact of deleting the company on its employees . because OnDelete
The value of is cascade
, When deleting a company , Its effect is cascading , Employees will also be deleted .
The first 106 Chapter Attribute keyword - Private
Specify whether the property is private ( Can only be used by methods of this class or its subclasses ).
usage
To specify that the property is private , Please use the following syntax :
Property name As classname [ Private ];
otherwise , Ignore the keyword or Not
Put before the keyword .
Detailed explanation
Private class members can only be represented by this class ( Or its subclass ) The method of using .
Private properties are not displayed in directory information , And not by SELECT *
Query returned . however , Can be in SQL Explicitly reference and use private attributes in queries .
A subclass inherits Private
The value of the keyword , It cannot be rewritten .
stay IRIS in , Private properties are always inherited , And visible to subclasses of classes that define attributes ; Other languages often call these protected properties .
Default
If you omit this keyword , Then this property is not private .
The first 107 Chapter Attribute keyword - ReadOnly
The specified attribute is read-only , This limits the way its value is set .
usage
To specify that the attribute is read-only , Please use the following syntax :
Property name As classname [ ReadOnly ];
otherwise , Omit this keyword or put the word Not
Put in front of the keyword .
Important note : Do not use ReadOnly
keyword .
Detailed explanation
This keyword specifies that the value of this property cannot be set by using an object reference . If you use an object reference to set the value of a read-only property , for example :
set oref.Name = "newvalue"
Then it will appear at runtime <CANNOT SET THIS PROPERTY>
error .
Again , When the attribute is defined as read-only , Corresponding SQL The fields in the table are also defined as read-only . Cannot pass SQL Statement to explicitly insert or update read-only fields . Trying to do this will lead to SQL error ,SQLCODE
by -138
.
You can specify the value of the read-only attribute in the following ways :
- adopt
InitialExpression
keyword . - adopt
SQLComputeCode
keyword .
Please note that , These technologies have specific limitations .
Be careful
If the attribute is marked as read-only and required required
, Please pay attention to object access and SQL The following behavioral differences between visits :
- When saving objects , IRIS Properties will not be validated . It means IRIS Ignored the
Required
keyword . - When inserting or updating records , IRIS Yes, it will
Required
keyword .
Default
If you omit this keyword , Then the attribute is not read-only .
The first 108 Chapter Attribute keyword - Required
For persistence classes , The value of the specified attribute must be given a value first , Then it can be stored to disk . For enabled XML
Class , It is necessary to specify the element to which the attribute is mapped .
usage
To specify attributes is required required
Of , Please use the following syntax :
Property name As classname [ Required ];
otherwise , Omit this keyword or put the word Not
Put in front of the keyword .
Detailed explanation
For persistent classes , This keyword specifies that before the containing object can be stored on disk , Attribute must be given a value ; If the attribute has no value , An error will occur .
- If the property is of type
%Stream
, Then the stream cannot be empty . in other words , If%IsNull()
Method returns 0, The flow attribute is considered to have a value . - For expansion
%XML.Adaptor
Class , This keyword affects the correspondingXML
framework . If the attribute is markedREQUIRED
, Then the corresponding element in the pattern does notminOccurs=“0”
, Therefore, it is considered necessary .
In a subclass , Optional attributes can be marked as required , But not vice versa .
Be careful
If the attribute is marked as read-only and required required
, Please pay attention to object access and SQL The following behavioral differences between visits :
- When saving objects , IRIS Properties will not be validated . It means IRIS Ignored the
Required
keyword . - When inserting or updating records , IRIS Yes, it will
Required
keyword .
Default
If you omit this keyword , The attribute is not required .
边栏推荐
- Leetcode——344. Reverse string /541 Invert string ii/151 Reverse the word / Sword finger in the string offer 58 - ii Rotate string left
- c#利用 TCP 协议建立连接
- Decrypt the three dimensional design of the game
- Internal sort - insert sort
- 用例图
- Source code analysis of ArrayList
- 课设之百万数据文档存取
- leetcode:648. 单词替换【字典树板子 + 寻找若干前缀中的最短符合前缀】
- JS get the current time, month, day, year, and the uniapp location applet opens the map to select the location
- Verilog implementation of a simple legv8 processor [4] [explanation of basic knowledge and module design of single cycle implementation]
猜你喜欢
常用数字信号编码之反向不归零码码、曼彻斯特编码、差分曼彻斯特编码
Multi merchant mall system function disassembly lecture 01 - Product Architecture
Horizontal of libsgm_ path_ Interpretation of aggregation program
多商户商城系统功能拆解01讲-产品架构
libSGM的horizontal_path_aggregation程序解读
OAuth 2.0 + JWT 保护API安全
Parsing of XML files
小米的芯片自研之路
The longest ascending subsequence model acwing 482 Chorus formation
Reverse non return to zero code, Manchester code and differential Manchester code of common digital signal coding
随机推荐
Oracle Linux 9.0 正式发布
oracle 非自动提交解决
Codes de non - retour à zéro inversés, codes Manchester et codes Manchester différentiels couramment utilisés pour le codage des signaux numériques
Cascading update with Oracle trigger
2022年13个UX/UI/UE最佳创意灵感网站
一个简单LEGv8处理器的Verilog实现【四】【单周期实现基础知识及模块设计讲解】
UML state diagram
最长上升子序列模型 AcWing 1012. 友好城市
Horizontal of libsgm_ path_ Interpretation of aggregation program
EMQX 5.0 发布:单集群支持 1 亿 MQTT 连接的开源物联网消息服务器
Leetcode——236. The nearest common ancestor of binary tree
CSMA/CD 载波监听多点接入/碰撞检测协议
搜索引擎接口
Excuse me, does PTS have a good plan for database pressure measurement?
多商戶商城系統功能拆解01講-產品架構
OAuth 2.0 + JWT 保护API安全
Excuse me, why is it that there are no consumption messages in redis and they are all piled up in redis? Cerely is used.
Excusez - moi, l'exécution a été réussie lors de l'utilisation des données de puits SQL Flink à Kafka, mais il n'y a pas de nombre dans Kafka
MicTR01 Tester 振弦采集模块开发套件使用说明
js 获取当前时间 年月日,uniapp定位 小程序打开地图选择地点