ADF Entities Association - Cascade Delete,Update
By raghu yadav on Jun 28, 2010
In this post we see how cascade delete enabled on associations. http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcentities.htm#sm0126
we know how referential integrity works at DB level. Lets create a 2 tables emp and dep with emp having relationship with dep.
create table dep (did number not null, dname varchar2(40), modified_by varchar2(40), modified_on Date, primary key (did));
create table emp (eid number not null, ename varchar2(40), did number,primary key (eid), foreign key(did) references dep(did));
create EO/VO/Links/Association using Create Business Component wizards ( normal process we follow ). This is how it looks after completion of creating EO/VO/Links/Assocation, you can also manually create assocations later if you had missed in wizard. Double click the association, you can notice nothing is checked by default.
However entity Association provides below list features, lets see how it behaves before selecting and after selecting these options.
- Implement Cascade Delete: When selected, this option allows the composing entity object to be removed unconditionally together with any composed children entities
- Cascade Update Key Attributes : When selected, it enable the automatic update of the foreign key attribute values in composed entities when the primary key value of the composing entity is changed.
- Locking of Composite Parent Entities : Select the Lock Top-Level Container to control whether adding, removing, or modifying a composed detail entity row should attempt to lock the composing entity before allowing the changes to be saved.
- Updating of Composing Parent History Attributes : Select the Update Top-Level History Columns option (see Figure 4-12) to control whether adding, removing, or modifying a composed detail entity object should update the Modified By and Modified On history attributes of the composing parent entity.
with unchecked History Update on Parent entities flag, you can notice modified date does not change upon updating the record in emp table.
with unchecked Implement Cascade delete flag, you can notice deleting department record throws error.