...
In the code snippet below, there is a User Entity which has an embedded ContactInfo. ContactInfo contains two other embeddeded embeddables, Address and Phone.
Code Block |
---|
title | Address.java |
---|
borderStyle | solid |
---|
|
No Format |
---|
@Embeddable
public class Address {
@Basic
private String street;
@Basic
private String city;
@Basic
private String state;
@Basic
private Integer zip;
public Address(){
}
//...
}
|
Code Block |
---|
title | Phone.java |
---|
borderStyle | solid |
---|
|
@Embeddable
public class Phone {
@Basic
private String number;
//...
}
|
Code Block |
---|
title | ContactInfo.java |
---|
borderStyle | solid |
---|
|
@Embeddable
public class ContactInfo {
public ContactInfo(){
}
@Embedded
Address homeAddress;
@Embedded
Phone homePhone;
//...
}
|
Code Block |
---|
title | User.java |
---|
borderStyle | solid |
---|
|
@Entity
public class User {
@Id
private int id;
@Embedded
ContactInfo contactInfo;
public User(){
}
//...
}
|
...