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

Intershop EDL code generator does not generate setter methods for PO objects

这是 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;
}

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

"The type TestPO must implement the inherited abstract method Test.setTest2UUID(String)"

我们是不是哪里做错了,还是 Intershop 代码生成器出错了?

感谢您的回答!

属性 test2UUID 被建模为必需的。就我而言,这将导致生成工厂 class 的创建操作需要一个参数。如果您检查 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;
}

如您所见,在接口级别上仅声明了关系,而不是作为关系一部分的外键属性。你可以试试这个方法。