121 words

Change Sequcene Id

2017-04-21 07:14

could I change sequcence id ?

allocating small value may not be effect.

or something other ways ?

javax.jdo.datastore.Sequence seq = em.unwrap(javax.jdo.PersistenceManager.class).getSequence("MyEntity$identity");
long currentValue = seq.currentValue();
// I would like to change currentValue (because it is too big value)
seq.allocate(smallValue); // allocating to small value is not effect

MyEntity is defined with JPA

public class MyEntity {
    private Long id;


Tsu's picture
Joined on 2013-02-12
User Post #1
2017-04-23 18:14

You cannot set the next id of an existing sequence. The purpose of the allocate(...) method is different (hint to improve efficiency by pre-allocating ids).

But you may define a new sequence with a new initial id, and set the relevant entity class to use the new sequence (note that you must verify that id collision is avoided and every entity object gets its own unique id).

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support's picture
Joined on 2010-05-03
User Post #2,750

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Maximum file size: 32 MB