I'm working on a personal project, desktop app for client and REST API server that handles all of database inquiries.
Here's my scenario.
I have a hibernate entity in high level
@Entity
@Table(name="Customer")
public class Customer {
private int id;
private int age;
// getters and setters
}
Client and server will use the same persistence class since even though it provides REST API, I'll be the only one working on the client.
The REST API v1 response for get Customer is
new ResponseEntity<Customer>(article, HttpStatus.OK);
Then the client will receive the Customer json and parse it back to Customer object.
Now my question is, if there's a change in Customer class, say age field got deleted and dob field is added, how do I manage this change on the server side?
I've read articles on creating versions but I cannot imagine how it can be done in a situation like this. v2 will use the most recent version of Customer class but then v1 will be unavailable (in other words it's response has changed) as v1's Customer class version does not exist anymore. Some were suggesting to use different packages for each versions and I don't think it's appropriate because that means all of the business logic that uses these persistence classes will also have to be put into different packages according to their versions.
I may be using the wrong structure so any advice is highly appreciated.