Orm Intershop EDL代码生成器不为PO对象生成setter方法
这是Intershop代码生成器的正常和预期行为吗?例如,如果您有以下接口Test.edl:Orm Intershop EDL代码生成器不为PO对象生成setter方法,orm,generator,intershop,Orm,Generator,Intershop,这是Intershop代码生成器的正常和预期行为吗?例如,如果您有以下接口Test.edl: cartridge interface Test extends PersistentObject { /* * Product ID */ attribute productID : string required; /* * Test2 UUID */ attribute test2UUID: uuid required;
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)进入interface Test.java,但由于以下编译器错误,将在没有它的情况下生成实现TestPO.java:
“TestPO类型必须实现继承的抽象方法Test.setTest2UUID(字符串)”
我们在这里是做错了什么,还是在Intershop代码生成器中出错了
谢谢你的回答 属性test2UUID根据需要建模。就我而言,这将导致在生成的factory类的创建操作上产生一个必需的参数。如果选中
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;
}
正如您所看到的,仅在接口级别声明了关系,而不是作为relation一部分的外键属性。您可以尝试这种方法。Thx,我可以看到,在通过工厂创建对象时必须指定所需的属性。但对于同样是外键的非必需属性,例如,如果不需要parentSlotID,并且您没有setter,该怎么办?是否需要,这应该不会对它产生任何影响。我能看到的唯一区别是接口测试将关系声明为强制关系(1..1)。SlotPageletAssignment不是这样的。好的,谢谢。我有setTest2(Test2)的方法,所以我将使用它,但我认为最好只设置Test2的UUID(setTest2UUID),这样我就不必在设置对它的引用之前从DB获取Test2对象。
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;
}