hybris中的部署代码有什么用?
what is the use of deployment code in hybris?
<itemtype code="IntegrationSystemCredentials" autocreate="true" generate="true">
<deployment **table**="IntegrationSystemCredentials" typecode="11000" />
</itemtype>
在上面的代码中,我提到了部署 table 和类型代码。为什么我们同时使用两者?
In the above code i have mentioned deployment table and typecode. why
we are using both?
简短的回答是:这是因为它们有不同的用途。
deployment table
使用 deployment table
,您将数据库 table 映射到 itemtype
。如果不提deployment table
,itemtype
的属性值将被保存到其父itemtype
的deployment table
中;换句话说,如果 itemtype
定义中没有 deployment table
,专利 itemtype
的数据库 table 将映射到 itemtype
.
如果您通过扩展 GenericItem
创建一个 itemtype
,您必须声明一个 deployment table
(一种避免 itemtype
的属性保存在 GenericItem
table)。但是,如果您要扩展其他 itemtype
例如Product
,您应尽可能避免声明 deployment table
,以避免在执行灵活搜索查询期间需要过多的联接。
请注意,GenericItem
是 itemtype
的默认父级,即如果您未在 itemtype
定义中声明 extends...
,则 itemtype
将,默认情况下,扩展 GenericItem
例如以下 itemtype
定义将无法编译,因为 DummyItem
默认扩展 GenericItem
但没有提及 deployment table
。
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="items.xsd">
<itemtypes>
<itemtype code="DummyItem" autocreate="true">
<attributes>
<attribute qualifier="uname" type="java.lang.String">
<modifiers read="true" write="true" search="true" initial="true" optional="false"/>
<defaultvalue>"Hello"</defaultvalue>
<persistence type="property"></persistence>
</attribute>
</attributes>
</itemtype>
</itemtypes>
</items>
typecode
typecode
属性是引用类型的唯一编号。 typecode 属性的值必须是介于 0
和 32767 (2^15-1)
之间的正整数,并且在整个 hybris 应用程序中必须是唯一的,因为它是 PK
生成机制的一部分,如下所示:
private static PK createPK_Counter(int typecode, long counter) {
if (typecode >= 0 && typecode <= 32767) {
//...
} else {
throw new IllegalArgumentException("illegal typecode : " + typecode + ", allowed range: 0-" + 32767);
}
}
what is the deployment table in hybris?
SAP Commerce 中的项目通过将值写入数据库来实现持久化。在数据库中,值存储在 table 中。 SAP Commerce 允许您明确定义数据库 tables,其中将写入给定类型实例的值。这可以通过定义部署标签来完成。
像。
<deployment table="mytype_deployment" typecode="12345" />
When to define the deployment table?
应该在
时为项目类型定义部署 table
您的项目类型没有扩展任何其他项目类型(默认情况下 GenericItem 除外)
您的项目类型扩展了没有部署的现有项目类型 table 定义
<itemtype code="IntegrationSystemCredentials" autocreate="true" generate="true">
<deployment **table**="IntegrationSystemCredentials" typecode="11000" />
</itemtype>
在上面的代码中,我提到了部署 table 和类型代码。为什么我们同时使用两者?
In the above code i have mentioned deployment table and typecode. why we are using both?
简短的回答是:这是因为它们有不同的用途。
deployment table
使用 deployment table
,您将数据库 table 映射到 itemtype
。如果不提deployment table
,itemtype
的属性值将被保存到其父itemtype
的deployment table
中;换句话说,如果 itemtype
定义中没有 deployment table
,专利 itemtype
的数据库 table 将映射到 itemtype
.
如果您通过扩展 GenericItem
创建一个 itemtype
,您必须声明一个 deployment table
(一种避免 itemtype
的属性保存在 GenericItem
table)。但是,如果您要扩展其他 itemtype
例如Product
,您应尽可能避免声明 deployment table
,以避免在执行灵活搜索查询期间需要过多的联接。
请注意,GenericItem
是 itemtype
的默认父级,即如果您未在 itemtype
定义中声明 extends...
,则 itemtype
将,默认情况下,扩展 GenericItem
例如以下 itemtype
定义将无法编译,因为 DummyItem
默认扩展 GenericItem
但没有提及 deployment table
。
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="items.xsd">
<itemtypes>
<itemtype code="DummyItem" autocreate="true">
<attributes>
<attribute qualifier="uname" type="java.lang.String">
<modifiers read="true" write="true" search="true" initial="true" optional="false"/>
<defaultvalue>"Hello"</defaultvalue>
<persistence type="property"></persistence>
</attribute>
</attributes>
</itemtype>
</itemtypes>
</items>
typecode
typecode
属性是引用类型的唯一编号。 typecode 属性的值必须是介于 0
和 32767 (2^15-1)
之间的正整数,并且在整个 hybris 应用程序中必须是唯一的,因为它是 PK
生成机制的一部分,如下所示:
private static PK createPK_Counter(int typecode, long counter) {
if (typecode >= 0 && typecode <= 32767) {
//...
} else {
throw new IllegalArgumentException("illegal typecode : " + typecode + ", allowed range: 0-" + 32767);
}
}
what is the deployment table in hybris?
SAP Commerce 中的项目通过将值写入数据库来实现持久化。在数据库中,值存储在 table 中。 SAP Commerce 允许您明确定义数据库 tables,其中将写入给定类型实例的值。这可以通过定义部署标签来完成。
像。
<deployment table="mytype_deployment" typecode="12345" />
When to define the deployment table?
应该在
时为项目类型定义部署 table您的项目类型没有扩展任何其他项目类型(默认情况下 GenericItem 除外)
您的项目类型扩展了没有部署的现有项目类型 table 定义