Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3313964
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:10:35+00:00 2026-05-17T22:10:35+00:00

I’ve just noticed that for my entity’s id, eclipselink assigns an id 1 +

  • 0

I’ve just noticed that for my entity’s id, eclipselink assigns an id 1 + the previously greated assigned IN THE SAME SESSION (1), as opposed to in the element table (2). This goes against my application expectations.

What’s the easiest way to tell it to do 2?

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int objId;

And here is what I have in the database:

ij> connect 'jdbc:derby:db';
ij> set schema memo;
0 Zeilen eingef?gt/aktualisiert/gel?scht
ij> select * from meaning;
OBJID      |LASTPUBLI&|USR_EMAIL                                                                                                                       
-------------------------------------------------------------------------------------------------------------------------------------------------------
1          |NULL      |NULL                                                                                                                            
2          |2010-10-27|NULL                                                                                                                            
51         |NULL      |NULL                                                                                                                            
101        |NULL      |NULL                                                                                      
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:10:36+00:00Added an answer on May 17, 2026 at 10:10 pm

    When using a GenerationType.AUTO strategy with Derby, EclipseLink defaults to a table generator strategy.

    Then, when generating an Id is required, EL will preallocate ids according to the allocationSize (which is 50 by default). To do so, it will first update the column that stores the last value generated to increment it by the allocationSize:

    UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
        bind => [50, SEQ_GEN]
    

    And will then read the new value:

    SELECT SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME = ?
        bind => [SEQ_GEN]
    

    Once done, EL preallocates a pool of ids using the current value – allocationSize + 1 as “first” and value as “last”:

    local sequencing preallocation for SEQ_GEN: objects: 50 , first: 1, last: 50
    

    And will serve ids from memory until it reaches the last value and will restart a cycle.

    Now, if you restart the JVM, there is just no other safe way for EL than preallocating a new pool of ids, “loosing” those from the “previous” range that haven’t been used (think multi-JVMs etc), which explains the “jump” from 2 to 51 in your example.

    If you want to avoid this, my suggestion would be to switch to an IDENTITY strategy which is supported by Derby (I don’t think that configuring the table generator to use an allocationSize of 1 would be a good idea).


    I don’t think that configuring the table generator to use an allocationSize of 1 would be a good idea. Why not?

    Because of the performance hit if you have to read from the “sequence” table for each insert. But on the other hand, 1) this might not be a concern in your case 2) That’s the only strategy that allows to get truly sequential ids.

    If you’re interested, you should be able to configure this globally using the table-generator element in the XML descriptor.

    EL highly discourages identity strategy, besides it seems there are mines (because you must wait to commit before reading the value, something I might be doing somewhere).

    Well, I can’t confirm for EL (I won’t test this right now) but Hibernate performs an immediate insert on persist when you use an IDENTITY strategy. I thought EL would behave in the same way. But I might be wrong, this doesn’t seem mandated by the spec.

    References

    • JPA Wikibook
      • Sequence Strategies
      • Advanced Sequencing Sequence Strategies
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a JSP page retrieving data and when single or double quotes are
I'm looking for suggestions for debugging... If you view this site in Firefox or
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.