[
https://issues.apache.org/jira/browse/OPENJPA-2913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153004#comment-18153004
]
ASF subversion and git services commented on OPENJPA-2913:
----------------------------------------------------------
Commit a7765b3f45a0a5d05d86e920126734f3f8bda482 in openjpa's branch
refs/heads/OPENJPA-2913 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=a7765b3f4 ]
[OPENJPA-2913] Keep a table sequence from reusing values after allocate()
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
>
> 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)