简体   繁体   中英

Jpa generatedValue skipping values

I have the next problem

POJO
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idUser;

@Email
@Column(length = 64, unique = true)
private String email;

When the email constrains fail, the next generated entity doesn't follow the previous id.

So, it goes like 1 2, (email constraint fails), 4. Jpa skipped number 3....

This is normal for many databases; to support concurrent transactions, underlying sequence numbers may be incremented by transactions that are later rolled back, but the database doesn't attempt to "fill in" the missing values, since it would be prohibitive to keep track of them.

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