简体   繁体   中英

how to manually set auto-generated id from lombok with mySQL workbench?

I have an app with a few entities annotated with lombok's @Data , and using

@Id
@GeneratedValue(strategy= GenerationType.AUTO)

for the id. It's generally working fine. But I needed to manually insert a row via mySQL Workbench, with id=635. This screwed up the app, when it tried to insert it's next row, because what it thought or calculated would be the next id, 635, already existed. I thought I could manually increment the id, but I couldn't find it anywhere via mySQL workbench.

So where does lombok/hibernate/jpa calculate or generate the next id? And is there a way to manually change it in the db, or at least with another SQL?

I'm not sure which framework does this, since it's using javax.persistence for the annotations, but also lombok.Data , and then in the app.properties, there is no dialect set, but I have a spring.jpa.hibernate.ddl key, so I'm not sure if that pulls in bits of hibernate as well.

I guess I needed to do more googling before posting. Found this answer here :

ALTER TABLE table_name AUTO_INCREMENT = 636;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM