简体   繁体   中英

Auto increment in hibernate(mysql) flush vs commit

We have one session running in per-thread which creates and processing multiple records in one table which have id as auto increment. While processing we are flushing data and at the end of thread we are committing it but if some exception occurs we rollback the current session in that thread.

So, how auto increment will work as in case of flush vs commit and if in mid it will rollback what will happen to auto increment id?

I have tried to find details on it but didn't find anything. Please help!!

Auto-increment id are "reserved" after flush, no any other sessions can use it It can't work another way. See good explanation https://stackoverflow.com/a/449387/4716980 by jmucchiello

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