Skip to content

Instantly share code, notes, and snippets.

@nakamura-to
Last active October 30, 2021 08:50
Show Gist options
  • Save nakamura-to/fac298a81966ce283589eb8647a41039 to your computer and use it in GitHub Desktop.
Save nakamura-to/fac298a81966ce283589eb8647a41039 to your computer and use it in GitHub Desktop.
Domaで@embeddableの代替策
public class Address {
public String ctiy;
public String street;
public Address(String city, String street) {
this.city = ctiy;
this.street = street;
}
}
@Entity
public class Emp {
private String ctiy1;
private String street1;
private String ctiy2;
private String street2;
public Address getAddress1() {
return new Address(city1, street1);
}
public void setAddress1(Address address) {
ctity1 = address.city;
street1 = address.street;
}
public Address getAddress2() {
return new Address(city2, street2);
}
public void setAddress2(Address address) {
ctity2 = address.city;
street2 = address.street;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment