Liferay Service Builder Table 每次部署自动递增

Liferay Service Builder Table Auto Increment On Each Deployment

在 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

将此添加到您的主键列中 id-type="increment"

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

缺点: 这将破坏集群环境

选项#2

在门户中添加这个-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

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