[
https://issues.apache.org/jira/browse/OPENJPA-2913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18154009#comment-18154009
]
ASF subversion and git services commented on OPENJPA-2913:
----------------------------------------------------------
Commit 93cdea96e971f9b7bede043919ced7aaeafa9bfd in openjpa's branch
refs/heads/OPENJPA-3106 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=93cdea96e ]
[OPENJPA-2913] Keep a table sequence from reusing values after allocate() (#330)
allocate() raised the upper bound of the in-memory block of a TableJDBCSeq
but left the next value where it was. On a fresh factory the sequence then
started at 1, and after next() calls it kept counting through values that
another factory had taken from the table in the meantime. Continue at the
value read from the table whenever the new range does not directly follow
the block already held.
> 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
> Assignee: Richard Zowalla
> Priority: Major
> Fix For: 4.3.0
>
>
> 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 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
(v10.3.26#10030026)