Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a MySQL table naming Invoice for a Inventory Monitoring site, invoice_number is bigint(19) AUTO_INCREMENT field.

Currently AUTO_INCREMENT value is 1.

Client want it to start the invoice_number from 50000. With the following script reset the ALTER TABLE INVOICES AUTO_INCREMENT = 50000; When I wrote an Insert Script to insert data in SQLDBX, it is putting the invoice_number from 50000. But when i am trying to do insert a record using the application(web application), the invoice_number value is starting from 1. We are making use of Spring-JDBC template to insert data into mysql database.

share|improve this question

closed as off topic by John Gardeniers, EEAA, Ward, Michael Hampton, mulaz Sep 26 '12 at 16:01

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 0 down vote accepted

The issue is with the Hibernate HBM mapping for Invoice. The generator class for Invoice Number is Increment.

<id name="invoiceNumber" column="INVOICE_NUMBER">
   <generator class="increment"/>

By modifying the generator class to identity it worked.

<id name="invoiceNumber" column="INVOICE_NUMBER">
    <generator class="identity"/>

For more detailed information, please check

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.