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

  • SEARCH
  • Home
  • 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 8587029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:27:58+00:00 2026-06-11T22:27:58+00:00

I have been going through the JPA documenation and came across pre allocation thing

  • 0

I have been going through the JPA documenation and came across pre allocation thing while assiging sequences id .

Though it is very good for obvious performances reasons.
But I was thinking about the scenario where it can mess up the things.

As I understand ,when we set the allocation size=100 when using table sequencing or sequencing objects as strategy for generating sequences, the persistence provider like hibernate or Eclipse link will maintain the memory counter and the application code for inserting records wont have to go database for each insert.

When that memory counter reaches 100,database sequence is incremented by 100 and same story continues.
All good till now.

But say we get a bug in the production where in we found that records in some of the tables arent being inserted into the DB.

So we prepare the script to insert those records in the DB,now what value we give to the primary keys of the table.If we take the value from the DB,there is a good chance that it will conflict when application tries to insert record using the memory counter and will give SQL exceptions.

Has anybody faced such issue?
And what is the best way to handle such situation?

  • 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-06-11T22:28:00+00:00Added an answer on June 11, 2026 at 10:28 pm

    Just make sure you use the same strategy as your Hibernate generator in the script. For example, if the sequence is at 2300, and the Hibernate generator increments the sequence by 100 and generates the ID 2301 to 2400 without going to the sequence, do the same in your script.

    Or stop the application, run your script, and regenerate the sequence with a value that guarantees that the Hibernate generator won’t generate an already used ID.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been going through some code and came across a statement that somehow
I've been going through an online UNIX course and have come across this question
I've been going through some old code, where I came across some custom defined
I have been going through the algorithm of uniform-cost search and even though I
I have been going through the core jQuery code and had a few why
I need to learn couchbd and have been going through tutorials on views. I
Recently, I have been going through search trees and I encountered red-black trees, the
I am complete newbie in mod_rewrite , and I have been going through some
I have been going through the docs and source code looking for something without
I have been going through and re-creating Apple's Advanced Table View Cells example to

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.