On execution of my spring boot application with MySQL as data source, it fails with below error message
Table 'schema.users_seq' doesn't exist
I have an @Entity class Users with an AUTO_INC field Id
@Entity
@Table(appliesTo = "users")
public class Users {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="uid")
private long id;
}
@RestController
@RequestMapping("/cm/api/user")
public class UserController {
@Autowired
UsersRepository usersRepository;
@GetMapping("/{username}")
public void getUser(@PathVariable("username") String userName) {
}
@PostMapping("/add")
public void addNewUser(@RequestBody Users users) {
usersRepository.save(users);
}
}
There are some other articles on the same issue, but it all ended with the question if the class has AUTO_INC field.
Your app tries to generate a long ID for your Users entity by retrieving a value from the users_seq. You need to change the @GeneratedValue(strategy = GenerationType.AUTO) according to your DDL structure. As you didn't include that in your post, I can only assume how you mapped it, so I can only recommend that you read this article by Hibernate maintainer Vlad Mihalcea about why you should not use the AUTO JPA GenerationType with MySQL and Hibernate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With