1

这是 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 类生成代码。您将使用方法 setTest2UUID(String aValue) 进入接口 Test.java,但没有它会生成实现 TestPO.java,并且由于以下编译器错误:

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

我们在这里做错了什么还是 Intershop 代码生成器中的错误?

谢谢您的回答!

4

1 回答 1

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

parentSlotID并且subPageletID都是两个关系使用的必需 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;
}

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

于 2018-10-05T13:13:07.577 回答