0

When I save any data, it'll save in id 4,14,24,etc. I want it to be in order like 1,2,3. Here is my code.

@Entity@Data@Table(name = "user") @NoArgsConstructor @AllArgsConstructor public class User {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idUser")
private Long idUser;

@Column(name = "name")
private String name;

@Column(name = "dob")
private Date DOB;

@Column(name = "address")
private String address;

@UpdateTimestamp
@Column(name = "updated_at")
private Date updatedAt;


@Column(name= "updated_by")
private String updatedBy;

@CreationTimestamp
@Column(name = "created_at")
private Date createdAt;}

Here is my DTO

@Data public class UserDTO {
private long idUser;
private String name;
private Date DOB;
private String address;
private Date updated_at;
private Date created_at;}

Here is my Service

@Slf4j @Service @AllArgsConstructor @NoArgsConstructor @Transactional public class UserService {
@Autowired
private UserRepository userRepository;

public User save( User request) {
    return userRepository.save(request);
}}

I only include some code in question so it will not be too long, but my code is like the one I use in photo. Here is the return from get: the IDs are 4 and id 14

Thank you in advance

Edit: I just found that the Id starts with 4 as default from addons ClearDB from heroku that I use

Syan
  • 21
  • 2
  • Sounds like your `auto_increment` starts with 4 and increases by 10 each time – XtremeBaumer Jun 23 '22 at 13:04
  • 1
    Does this answer your question? [How is the MySQL auto\_increment step size determined](https://stackoverflow.com/questions/8262863/how-is-the-mysql-auto-increment-step-size-determined) – XtremeBaumer Jun 23 '22 at 13:04

0 Answers0