When using spring boot jpa, I encountered an issue. Every time after saving, I get a return value, where the id is generated only after saving to the database. So when I try to retrieve it, I find that it is 0, the id of the returned object is 0, indicating that the save()
method does not return the object after saving.
After some research, I found that I need to add @GeneratedValue(strategy = GenerationType.IDENTITY)
annotation to the id field of the Entity to return the latest id.