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 6367505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:33:21+00:00 2026-05-25T00:33:21+00:00

I have configured hibernate to use oracle sequence. Sequence is created with cache=20, increment=1.

  • 0

I have configured hibernate to use oracle sequence. Sequence is created with cache=20, increment=1.

All works fine, hibernate persisting entities. The id value is strange: 50,51….76,201,202…209,1008,1009,5129,5130 ….

If I ask for sequence value (select hibernate_sequence.nextval from dual) I get value like 2,3,4 ….

If I turn on hibernate sql debug, there is time to time call “select hibernate_sequence.nextval from dual” but number assigned by hibernate to ID doesn’t relay on sequence!

@Id
@Column(name = "ID", insertable = false, updatable = false)
@SequenceGenerator(name = "SequenceIdGenerator", sequenceName = "HIBERNATE_SEQUENCE")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SequenceIdGenerator")
private Long id;
  • 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-25T00:33:21+00:00Added an answer on May 25, 2026 at 12:33 am

    This is because the SequenceGenerator is not really a sequence generator. It’s a sequence hi-lo generator. This means that the first time it’s invoked, it gets the next value from the sequence (6 for example), then multiplies this value by 50 and gives you the result (300). The next time it’s invoked, it returns 301 (without going to the sequence), and so on until it reaches 349. Then it asks the sequence for the next value and obtains 7, which it multiplies by 50 again to give you 350. My algorithm description could be off by one, but you get the idea.

    If you stop and start your application, it will thus have gaps. But it’s more efficient than a pure sequence generator because it only makes a database call once in 50 generations.

    See http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#mapping-declaration-id-enhanced-optimizers and http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#mapping-declaration-id-generator for details.

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

Sidebar

Related Questions

I have configured Tomcat to use LDAP / AD. How can I get more
I have configured my application to use form based authentication and set up the
I have a C# WinForms application with a database backend (oracle) and use NHibernate
I have a Spring/JPA application with Hibernate as the JPA provider. I've configured a
I have a problem regarding the use of hibernate.properties and c3p0.properties. I am dependent
Here is my scenario: I have my-jsf-app.war (JSF 1.2 application) and daos-and-entities.har (Hibernate 3.3.1)
I currently have Spring configured to use HSQL, but I would like to use
I have been learning to use hibernate for a couple of months. I am
I have configured my default page to be say abcd.aspx and is under ~/View//abcd.aspx
I have configured Tomcat 6 to serve Perl CGI scripts. That part is well

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.