简体   繁体   English

Intershop EDL建模-如何通过级联删除添加依赖项

[英]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). 我们有一些通过EDL建模的自定义对象,这些对象具有系统Intershop对象(ISPRODUCT和ISORDER)的外键。 We need our objects to get deleted when referenced order or product is deleted. 当引用的订单或产品被删除时,我们需要删除对象。

This is the extract from the EDL file: 这是EDL文件的摘录:

/**
 * 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. 如我所见,可以在EDL关系上添加删除操作,但不能在依赖项上添加删除操作。

What we are doing at the moment is modifying the statements in the generated dbconstraints.oracle.ddl files like this: 目前,我们正在做的就是修改生成的dbconstraints.oracle.ddl文件中的语句,如下所示:

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. 但这只是暂时的解决方法,因为每次我们在EDL上重新启动代码生成器时,这些文件都会被覆盖。

On relationship it is possible to define the on delete action like this: 在关系上,可以这样定义on删除操作:

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. 很高兴知道,我不知道EDL可以做到这一点。 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. 我用这种方法的问题是,orm缓存不知道oracle正在删除这些对象,因此它可能使幻影对象在orm缓存中浮动。

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. 我确实想知道代码生成器如何处理关系上的此delete属性。

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. 由于依赖关系只是orm无法自动删除的弱(单向)关系。 See here for documentation about EDL-dependency: https://support.intershop.com/kb/index.php/Display/247P28 请参阅此处以获取有关EDL依赖性的文档: https : //support.intershop.com/kb/index.php/Display/247P28

For example, I checked ProcessPagelet-Delete pipline. 例如,我检查了ProcessPagelet-Delete pipline。 In there we first unassign ( ie remove the assignment ) Label objects from the Pagelet to be deleted. 在这里,我们首先从要删除的Pagelet 取消分配( 即删除分配Label对象。 The PageletLabelAssingmentPO contains a dependency to Pagelet as you can see here: 如您在此处看到的那样, PageletLabelAssingmentPO包含对Pagelet的依赖关系:

orm class PageletLabelAssignmentPO extends LabelAssignmentPO
{
    attribute pageletUUID : uuid;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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