@Target(value=TYPE)
@Retention(value=RUNTIME)
public @interface Embeddable
The embeddable class can be embedded into an entity class.
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.