2

在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。

4

1 回答 1

5

选项1

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

IE

<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

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

于 2017-07-14T05:42:43.503 回答