Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
titleAddress.java
borderStylesolid
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
titlePhone.java
borderStylesolid
@Embeddable
public class Phone {
	@Basic
	private String number;
//...
}
Code Block
titleContactInfo.java
borderStylesolid
@Embeddable
public class ContactInfo {
	public ContactInfo(){	
	}
	
	@Embedded
	Address homeAddress;
	
	@Embedded
	Phone homePhone;
//...
}
Code Block
titleUser.java
borderStylesolid
@Entity
public class User {
	@Id
	private int id;
	@Embedded
	ContactInfo contactInfo;
	
	public User(){
	}
//...
}

...