英文:
what is the use of deployment code in hybris?
问题
<itemtype code="IntegrationSystemCredentials" autocreate="true" generate="true">
<deployment table="IntegrationSystemCredentials" typecode="11000" />
</itemtype>
在上述代码中,我已经提到了部署表和类型代码。为什么我们同时使用这两者呢?
英文:
<itemtype code="IntegrationSystemCredentials" autocreate="true" generate="true">
<deployment **table**="IntegrationSystemCredentials" typecode="11000" />
</itemtype>
In the above code i have mentioned deployment table and typecode. why we are using both?
答案1
得分: 1
> 在上面的代码中,我已经提到了部署表和类型代码(typecode)。为什么我们要同时使用它们呢?
简短的回答是:因为它们有不同的用途。
部署表
(deployment table)
使用部署表
,您将数据库表映射到itemtype
。如果您不提到部署表
,itemtype
的属性值将保存在其父itemtype
的部署表
中;换句话说,在itemtype
定义中缺少部署表
的情况下,父itemtype
的数据库表将与itemtype
映射。
如果您通过扩展GenericItem
来创建itemtype
,则必须声明一个部署表
(这是一种避免itemtype
的属性保存在GenericItem
表中的机制)。然而,如果您扩展了其他一些itemtype
,例如Product
,应尽量避免在执行Flexible Search Query时声明部署表
,以避免需要太多的连接操作。
请注意,GenericItem
是itemtype
的默认父类型,即如果在itemtype
定义中不声明extends...
,则itemtype
将默认扩展为GenericItem
。例如,以下itemtype
定义将无法编译,因为DummyItem
默认扩展为GenericItem
,但没有为其指定部署表
。
<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)
类型代码
属性是引用类型的唯一数字。类型代码
属性的值必须是介于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);
}
}
英文:
> In the above code i have mentioned deployment table and typecode. why
> we are using both?
The short answer is: It's because they serve different purposes.
deployment table
Using deployment table
, you map a database table to the itemtype
. If you do not mention deployment table
, the values of the attributes of the itemtype
will be saved into the deployment table
of its parent itemtype
; in other words, in absence of the deployment table
in the itemtype
definition, the database table of the patent itemtype
will be mapped with the itemtype
.
If you are creating an itemtype
by extending GenericItem
, you must declare a deployment table
(a mechanism to avoid the attributes of the itemtype
getting saved in GenericItem
table). However, if you are extending some other itemtype
e.g. Product
, you should avoid declaring deployment table
as much as possible in order to avoid too many joins required during the execution of the Flexible Search Query.
Note that GenericItem
is the default parent of an itemtype
i.e. if you do not declare extends...
in the itemtype
definition, the itemtype
will, by default, extend GenericItem
e.g. the following itemtype
definition will fail compilation because DummyItem
extends GenericItem
by default but there is no deployment table
mentioned for it.
<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
The typecode
attribute is a unique number to reference the type. The value of the typecode attribute must be a positive integer between 0
and 32767 (2^15-1)
and must be unique throughout your hybris application as it is part of the PK
generation mechanism as shown below:
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);
}
}
答案2
得分: 0
> 什么是Hybris中的部署表?
SAP Commerce中的项通过将值写入数据库而变为持久化。在数据库内,这些值被存储在表中。SAP Commerce允许您明确地定义实例值将被写入的给定类型的数据库表。这可以通过定义部署标签来实现。例如:
<deployment table="mytype_deployment" typecode="12345" />
> 何时定义部署表?
当以下情况之一成立时,应为项目类型定义部署表:
-
您的项目类型不扩展任何其他项目类型(默认情况下除外的GenericItem类型)
-
您的项目类型扩展了尚未定义部署表的现有项目类型
了解更多信息,请阅读为平台类型指定部署
英文:
> what is the deployment table in hybris?
Items within SAP Commerce are made persistent by writing values into a database. Within the database, the values are stored in tables. SAP Commerce allows you to explicitly define the database tables where the values of instances of a given type will be written. This can be done by defining the deployment tag.
Like.
<deployment table="mytype_deployment" typecode="12345" />
> When to define the deployment table?
One should define the deployment table for an item type when
-
Your item type doesn't extend any other item type (except GenericItem, which is by default)
-
Your item type extend existing item type for which there is no deployment table defined
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论