【问题标题】:what is the use of deployment code in hybris?hybris中部署代码的用途是什么?
【发布时间】:2020-12-18 09:28:02
【问题描述】:
<itemtype code="IntegrationSystemCredentials" autocreate="true" generate="true">
                <deployment **table**="IntegrationSystemCredentials" typecode="11000" />
</itemtype>

在上面的代码中,我提到了部署表和类型代码。为什么我们同时使用两者?

【问题讨论】:

    标签: java hybris


    【解决方案1】:

    在上面的代码中,我提到了部署表和类型代码。为什么 我们两个都用?

    简短的回答是:这是因为它们的用途不同。

    deployment table

    使用deployment table,您可以将数据库表映射到itemtype。如果不提及deployment table,则itemtype的属性值将保存到其父itemtype的deployment table中;也就是说,在itemtype定义中没有deployment table的情况下,专利itemtype的数据库表将与itemtype进行映射。

    如果您通过扩展GenericItem 创建itemtype,则必须声明deployment table(一种避免itemtype 的属性保存在GenericItem 表中的机制)。但是,如果您要扩展其他一些 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);
        }
    }
    

    查看this 和this 了解更多信息。

    【讨论】:

      【解决方案2】:

      hybris中的部署表是什么?

      SAP Commerce 中的项目通过将值写入数据库来实现持久化。在数据库中,值存储在表中。 SAP Commerce 允许您明确定义将写入给定类型实例值的数据库表。这可以通过定义部署标签来完成。
      喜欢。 &lt;deployment table="mytype_deployment" typecode="12345" /&gt;


      什么时候定义部署表?

      应该为项目类型定义部署表

      • 您的项目类型不扩展任何其他项目类型(GenericItem 除外,默认情况下)

      • 您的项目类型扩展了未定义部署表的现有项目类型

      阅读更多Specifying a Deployment for Platform Types

      【讨论】:

        猜你喜欢
        • 2020-09-14
        • 1970-01-01
        • 2010-10-14
        • 2021-07-29
        • 2020-11-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多