Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 professional 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.

1 Answer 1

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"/>
</id>

By modifying the generator class to identity it worked.

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

For more detailed information, please check http://stackoverflow.com/questions/1838520/hibernate-problems-with-auto-increment-id-mysql-5

share|improve this answer

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