THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
Collections Embeddables
Relationships Embeddables
Nested Embeddables
In the code snippet below, there is a User Entity which has an embedded ContactInfo. ContactInfo contains two other embeddeded embeddables, Address and Phone.
Address.java
@Embeddable public class Address { @Basic private String street; @Basic private String city; @Basic private String state; @Basic private Integer zip; public Address(){ } //... }
Phone.java
@Embeddable public class Phone { @Basic private String number; //... }
ContactInfo.java
@Embeddable public class ContactInfo { public ContactInfo(){ } @Embedded Address homeAddress; @Embedded Phone homePhone; //... }
User.java
@Entity public class User { @Id private int id; @Embedded ContactInfo contactInfo; public User(){ } //... }