Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2913

TableJDBCSeq can generate duplicate IDs if allocate() is called

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.1.2
    • None
    • kernel
    • None

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            darnap Dario Napolitano
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: