Liferay Service Builder表每个部署的自动增量

时间:2017-07-14 05:16:21

标签: liferay liferay-service-builder

在liferay中我有一个实体如下:

<entity name="Foo" local-service="true" remote-service="true">

        <!-- PK fields -->

        <column name="fooId" type="long" primary="true" />

        <!-- Group instance -->

        <column name="groupId" type="long" />

        <!-- Audit fields -->

        <column name="companyId" type="long" />
        <column name="userId" type="long" />
        <column name="userName" type="String" />
        <column name="createDate" type="Date" />
        <column name="modifiedDate" type="Date" />

        <!-- Other fields -->

        <column name="field1" type="String" />
        <column name="field2" type="boolean" />
        <column name="field3" type="int" />
        <column name="field4" type="Date" />
        <column name="field5" type="String" />

        <!-- Order -->

        <order by="asc">
            <order-column name="field1" />
        </order>

        <!-- Finder methods -->

        <finder name="Field2" return-type="Collection">
            <finder-column name="field2" />
        </finder>
    </entity>

当我更改portlet的代码时。在每次部署时,其主键增加100。 所以无论如何都要将它自动增量设置为1。并且每次部署时不得增加100。

1 个答案:

答案 0 :(得分:4)

选项#1

在主键列id-type="increment"

中添加此项

<column name="fooId" type="long" primary="true" id-type="increment" />

<强>缺点: 这将在聚集环境中突破

选项#2

在portal-ext.properties

中添加
#
# Set the number of increments between database updates to the Counter
# table. Set this value to a higher number for better performance.
#
counter.increment=1 //by default it is 100

缺点:这会影响您的表现。