I am currently creating a simple application with my friend and we cannot decide how should we separate certain objects. For example in a rest controller which receives a "UserRequest" in the request
public class UserRequest{
private String id;
private String username;
}
We are going to use this for other API integration or validation logic, but at the same time, we are going to insert the User into a MySQL Table, now usually we use annotations like @Entity, @Table to define that this object is going to be used in the DB Repo.
@Entity
public class User{
private String id;
private String username;
private Date gmtCreate;
}
now on a high level the "gmtCreate" is the field difference, however there can be other datbaase related fields that we can add that does not matter on the UserRequest object but basically they are mostly redundant.
Need help to decide whether we should create separate objects 1 - User (used for rest controller and java logic operations), 2 - UserDBObject (used for database operations)
or should we unify them into a single object User and ignore fields based on the usage.