You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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.

 
@Embeddable
public class Address {
	@Basic
	private String street;
	@Basic
	private String city;
	@Basic
	private String state;
	@Basic
	private Integer zip;

	public Address(){
	}
//...
}

@Embeddable
public class Phone {
	@Basic
	private String number;
}

@Embeddable
public class ContactInfo {
	public ContactInfo(){	
	}
	
	@Embedded
	Address homeAddress;
	
	@Embedded
	Phone homePhone;
//...
}

@Entity
public class User {
	@Id
	private int id;
	@Embedded
	ContactInfo contactInfo;
	
	public User(){
	}
//...
}

Collections Embeddables

Relationships Embeddables

  • No labels