Annotation Interface Embeddable


@Target(TYPE) @Retention(RUNTIME) public @interface Embeddable
Indicates a class that can be embedded within an entity class.

An embeddable class represents a reusable component that groups related properties which can be embedded into one or more entity classes.

The embeddable class must have a non-private constructor that accepts all properties of the class as arguments.

 @Embeddable
 public class Address {

     @Column(name = "CITY")
     private final String city;

     @Column(name = "STREET")
     private final String street;

     public Address(String city, String street) {
         this.city = city;
         this.street = street;
     }
     ...
 }
 
 @Entity
 public class Employee {

     @Id
     @Column(name = "ID")
     Integer id;

     Address address;

     @Version
     @Column(name = "VERSION")
     int version;

     ...
 }
 

The embeddable instance is not required to be thread safe, as it is typically used within the context of a single entity instance.