The UserAddress classes will suffer just a single change from the monolith version, but keep their original APIs (that is great from the point of view of the client).
Here is the UserAddress entity:
@Entity
public class UserAddress implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column
private Long idUser;
@Column
private String street;
@Column
private String number;
@Column
private String city;
@Column
private String zip;
public UserAddress(){
}
public UserAddress(Long user, String street, String number,
String city, String zip) {
this.idUser = user;
this.street = street;
this.number = number;
this.city = city;
this.zip = zip;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getIdUser() {
return idUser;
}
public void setIdUser(Long user) {
this.idUser = user;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
}
Note that User is no longer a property/field in the UserAddress entity, but only a number (idUser). We will get into more details about it in the following section.