DataManger.GetReference increases the underlying sequence

Hi,

When doing dataManager.getReference(MyEntity.class, 1234), I remark that the underlying sequence is being incremented (MyEntity is using a sequence for the PK).

Obviously this has 2 impacts:

  • It slows down the getReference
  • It increases unexpectedly the number of generated IDs, potentially creating abnormally high internal ID to the point of having an overflow

This happens because the metadata.create is calling every listener in the internalCreate, including the GenerateNumberIdEntryInitializer which goes and get the next ID if none are present.

A quick solution would be to add an create method parameter to the create methods to pass the ID and set the ID in the create before executing the listeners, so there would be no generation of ID.

Best regards

Thierry

Hi Thierry,

Thank you for the report and the suggested solution. It makes perfect sense.
Created issue.

Regards,
Konstantin

1 Like