Hybris generates an existing PK

We recently migrated Hybris 5.4 to Hybris 6.5, but since it generates an existing PK (we are working with the same database that has some records).

In the development environment, we have:

  • All existing entries are deleted.
  • Re-performed the save operation until a new PK was created.

But now we are afraid that we will have the same problem in production, and we will not be able to do this.

What can we do to make Hybris review the old PK?

+4
source share
2 answers

The previous comment that reads:

Do you have this problem for a specific type? If yes! You might consider changing your deployment table numbre table to get a new PK.

, PK , groovy script, .

, XML- , typecode: 45.

<itemtype code="Order" extends="AbstractOrder" jaloclass="de.hybris.platform.jalo.order.Order" generate="true" singleton="false" jaloonly="false" autocreate="true">
    <deployment table="orders" typecode="45"/>

groovy :

import de.hybris.platform.core.Registry;
import de.hybris.platform.core.PK.PKCounterGenerator;
import de.hybris.platform.persistence.numberseries.SerialNumberGenerator;

int key = 45;
int current = new de.hybris.platform.core.DefaultPKCounterGenerator().fetchNextCounter(key);
SerialNumberGenerator generator = Registry.getCurrentTenant().getSerialNumberGenerator();
generator.removeSeries("pk_"+key);
generator.createSeries("pk_"+key,1,current*10)

, . - , , .

+1

(, hac), "counter.pk.generator.class", , PK Hybris. , , .

+3

Source: https://habr.com/ru/post/1693516/


All Articles