0

my project using Auto increment in my hybernate entity table. every new records is save then

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

the "id" is auto increment 3 by 3. like

1051
1054
1057

any solution to fix this issue. please help me.

diiN__________
  • 7,393
  • 6
  • 42
  • 69
  • 1
    can you paste the o/p of `show create table` command in mysql ? – Amit Oct 06 '17 at 05:51
  • Why do you care about the id generation if you use `GenerationType.AUTO`? Why don't you use `SEQUENCE` instead? – Flown Oct 06 '17 at 05:53
  • @Flown MySQL doesn't support `SEQUENCE` – Himanshu Bhardwaj Oct 06 '17 at 06:00
  • hi @Flown my project already set entity field id is GenerationType.AUTO. SEQUENCE The SEQUENCE generator (defined in the SQL:2003 standard) is supported by: Oracle SQL Server PostgreSQL DB2 HSQLDB only. here not support mysql. >> https://dzone.com/articles/hibernate-identity-sequence – Rajagopal S Oct 06 '17 at 06:02
  • My question persists. Why do you care about the id generation if you're using the `AUTO` type? `SEQUENCE` was just a random example. If MySQL doesn't support `SEQUENCE` you have to use `TABLE` for example instead. – Flown Oct 06 '17 at 06:26

2 Answers2

1

Try using a sequence in your db. It will make it auto increment sequentially.

here is the more details

shanika yrs
  • 303
  • 1
  • 13
0

Its My SQL DB Fault.

default db system auto increment value is set 3 that's call its Auto incremented 3 by 3 every insert.

If u want to check and update mysql system auto increment value then

SHOW VARIABLES LIKE 'auto_inc%'; SET @@auto_increment_increment=1;

Then its fixed thanks guys.

More info >> https://dev.mysql.com/doc/refman/5.6/en/replication-options-master.html