Package org.hibernate.annotations
Annotation Interface PropertyRef
@Target({FIELD,METHOD,ANNOTATION_TYPE})
@Retention(RUNTIME)
@Incubating
public @interface PropertyRef
Allows to specify the target of a foreign-key using a "target attribute" as opposed to
join column(s). E.g.
Generally more useful with composite keys:@Entity
class Employee {@Id
Integer id;@Column(name="ssn")
String socialSecurityNumber; }@Entity
class TaxDetails {@Id Integer id;
@OneToOne
@PropertyRef("socialSecurityNumber")
Employee employee; }
@Embeddable
class Name { String first; String last; }@Entity
class Employee {@Id
Integer id;@Embedded
Name name; }@Entity
class TaxDetails {@Id Integer id;
@OneToOne
@PropertyRef("name")
Employee employee; }
- API Note:
- As Hibernate allows OneToMany.mappedBy() and ManyToMany.mappedBy() to refer to basic and embedded attributes already, this annotation is mainly useful for mapping to-one associations.
-
Required Element Summary
Required Elements
-
Element Details
-
value
String valueThe name of the attribute on the target entity which defines the foreign-key target.
-