You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Dario Napolitano (Jira)" <ji...@apache.org> on 2023/07/20 08:01:00 UTC

[jira] [Updated] (OPENJPA-2913) TableJDBCSeq can generate duplicate IDs if allocate() is called

     [ https://issues.apache.org/jira/browse/OPENJPA-2913?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dario Napolitano updated OPENJPA-2913:
--------------------------------------
    Summary: TableJDBCSeq can generate duplicate IDs if allocate() is called  (was: TableJDBCSeq can genarate duplicate IDs if allocate() is called)

> TableJDBCSeq can generate duplicate IDs if allocate() is called
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-2913
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2913
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 3.1.2
>            Reporter: Dario Napolitano
>            Priority: Major
>
> When using the allocate() method of the ID generator of an entity using table based generation (TableJDBCSeq), the generator will start from 1 no matter what is the current value of the sequence, if it's the first allocation. If a new allocation takes place, the generator is likely to use values already allocated to other entities.
> Example:
> OpenJPAEntityManager oem = (OpenJPAEntityManager) em;
> Generator idGenerator = oem.getIdGenerator(User.class);
> idGenerator.allocate(1000);
>  
> This is because the TableJDBCSeq does not update the current sequence value during allocate() calls, but only during next() calls. However, the allocate() method is exposed via the Generator interface to request preallocation for efficiency.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)