Intershop EDL代码生成器不会为PO对象生成setter方法

时间:2018-10-05 08:13:13

标签: orm generator intershop

Intershop代码生成器是否具有这种正常预期的行为?例如,如果您具有以下Test.edl接口:

cartridge interface Test extends PersistentObject
{
    /*
     * Product ID
     */
    attribute productID : string required;

    /*
     * Test2 UUID
     */
    attribute test2UUID: uuid required;

    /**
     * Test2 relation
     */
    relation test2: Test2[1..1] readonly;

    /*
     * Product relation
     */
    relation product : Product[1..1] readonly;
}

cartridge interface Test2 extends PersistentObject
{
    relation test2values : Test[0..n] readonly;
}

这是PO对象:

orm class TestPO extends PersistentObjectPO implements Test table "Test"
{
     /**
     * Declare alternate key.
     */
    alternate key (test2UUID, productID, domainID);

    /**
     * Holds link to test2.
     */
    attribute test2UUID: uuid required;

    /**
     * Holds link to product.
     */
    attribute productID : uuid required;

    /**
     * Relation to test2 PO
     */
    relation test2PO : Test2PO[1..1] inverse testPOs implements test2 readonly 
    {
        foreign key(test2UUID) -> (UUID);
    }

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

}

orm class Test2PO extends PersistentObjectPO implements Test2 table "Test2" {
    /**
     * Discount values relation
     */
    relation testPOs : TestPO[0..n] inverse test2PO implements test2values delete default;
}

现在,如果您同时为interface和orm类生成代码。您将使用方法setTest2UUID(String aValue)进入Test.java接口,但是由于以下编译器错误,将在没有该接口的情况下生成TestPO.java实现:

“类型TestPO必须实现继承的抽象方法Test.setTest2UUID(String)”

我们在这里做错什么了吗?还是Intershop Code Generator中的错误?

谢谢您的回答!

1 个答案:

答案 0 :(得分:1)

根据需要对属性test2UUID进行建模。就我而言,这将导致在生成的工厂类的创建操作上需要一个参数。如果您选中SlotPageletAssignmentPO,则其建模方式非常相似。

orm class SlotPageletAssignmentPO extends PersistentObjectPO implements SlotPageletAssignment table "SlotPageletAssignment"
{
    attribute id : string<256> required readonly;

    attribute parentSlotID : uuid required;

    attribute subPageletID : uuid required;

    attribute validFrom : datetime;

    attribute validTo : datetime;

    attribute online : boolean;

    attribute position : double required;

    relation subPageletPO : PageletPO[1..1] inverse parentSlotPageletAssignmentPOs implements subPagelet readonly
    {
        foreign key(subPageletID) -> (UUID);
    }

    relation parentSlotPO : SlotPO[1..1] inverse slotSubPageletAssignmentPOs implements parentSlot readonly
    {
        foreign key(parentSlotID) -> (UUID);
    }

    relation placeholderPO : SlotPageletAssignmentPlaceholderPO[0..n] inverse assignment readonly;
}

parentSlotIDsubPageletID都是两个关系使用的必需UUID,这两个关系都实现在capi接口中声明的关系。

cartridge interface SlotPageletAssignment extends PageletAssignment
{
    attribute id: string required readonly;

    attribute online : boolean;

    attribute validFrom : datetime;

    attribute validTo : datetime;

    attribute position : double required;

    /*
     * @deprecated Use {@link #getTo()} instead
     */
    relation parentSlot : Slot[0..1] readonly;

    /*
     * @deprecated Use {@link #getFrom()} instead
     */
    relation subPagelet : Pagelet[0..1] readonly;
}

如您所见,仅在接口级别声明了关系,而未声明属于关系的外键属性。您可以尝试这种方法。