Since your id
is auto-generated in Account.java
, you should not pass it manually in Postman.
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
✅ Correct JSON request (without id
):
{ "accountHolderName": "Piyush", "balance": 1000.00 }
This allows Spring Boot and JPA to handle id
generation.
Possible Issues If You Pass id
Manually
Spring Boot might not bind the request properly, leading to 404 Not Found
.
JPA may throw an error if it expects an auto-generated value but receives one manually.
If your database is empty, id = 1 does not exist, causing your GET
requests to fail.