Defining Embeddable Class Mapping

Embeddable classes are simple Value type classes. Follow the instructions for defining Value type class mappings to define Embeddable class mapping for EJB 3.

In EJB 3, Embeddable classes can contain only attribute mappings, and these persistent attributes can have only basic types, i.e. Embeddable classes cannot contain nested Embeddable classes.

Note: The Embeddable class must implement the java.io.Serializable interface and overrides the equals() and hashCode() methods.

The Embeddable annotation is generated to specify a class whose instances are stored as an intrinsic part of an owning entity and share the identity of the entity.

@Embeddable
public class Address implements java.io.Serializable {
  @Basic(optional=true)
  @Column(name="address_country")
  public String getCountry() {}
  .....
}