1

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.

John Gardeniers
  • 27,262
  • 12
  • 53
  • 108

1 Answers1

0

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 https://stackoverflow.com/questions/1838520/hibernate-problems-with-auto-increment-id-mysql-5