简体   繁体   中英

Intershop EDL modelling - How to add dependency with on cascade delete

We have some custom objects modelled through EDL which have foreign keys to system Intershop objects (ISPRODUCT and ISORDER). We need our objects to get deleted when referenced order or product is deleted.

This is the extract from the EDL file:

/**
 * Relation to product PO (tariff item)
 */
dependency tariff: ProductPO
{
  foreign key(tariffID);
}

/*
 * Order relation
 */
dependency order: OrderPO
{
  foreign key(orderID);
}

As I can see, it is possible to add delete actions on EDL relations but it is not possible to add delete actions on dependencies.

What we are doing at the moment is modifying the statements in the generated dbconstraints.oracle.ddl files like this:

EXEC staging_ddl.add_constraint('A1APPLICATIONFORM', 'A1APPLICATIONFORM_CO_003', 'FOREIGN KEY (TARIFFID) REFERENCES PRODUCT (UUID) ON DELETE SET NULL INITIALLY DEFERRED DEFERRABLE DISABLE NOVALIDATE');
EXEC staging_ddl.add_constraint('A1APPLICATIONFORM', 'A1APPLICATIONFORM_CO_004', 'FOREIGN KEY (ORDERID) REFERENCES ISORDER (UUID) ON DELETE CASCADE INITIALLY DEFERRED DEFERRABLE DISABLE NOVALIDATE');

But it is only the temporary workaround because these files will get overwritten each time we restart the code generator on the EDL.

On relationship it is possible to define the on delete action like this:

relation promotionBenefitPOs : A1PromotionBenefitPO[0..n] inverse promotionPO implements promotionBenefits delete default;

Is it possible to achieve the same thing on the dependency with the system objects?

I didn't know that was possible with EDL, good to know. My problem with this approach is that the orm cache does not know that these objects are being removed by oracle, so it might have phantom object floating around in the orm cache.

I would use this register listener solution to remove these objects so that everything is updated and flushed out of the cache.

I do wonder how the code generator deals with this delete property on the relation.

I'm afraid you need to do that by hand. Meaning once an instance of the types involved is removed, you need to query for your custom glue object and remove that one a subsequent action by your own. As dependency is merely a weak (unidirectional) relation that orm cannot automatically remove. See here for documentation about EDL-dependency: https://support.intershop.com/kb/index.php/Display/247P28

For example, I checked ProcessPagelet-Delete pipline. In there we first unassign ( ie remove the assignment ) Label objects from the Pagelet to be deleted. The PageletLabelAssingmentPO contains a dependency to Pagelet as you can see here:

orm class PageletLabelAssignmentPO extends LabelAssignmentPO
{
    attribute pageletUUID : uuid;

    dependency pagelet : PageletPO
    {
        foreign key(pageletUUID);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM