Annotation Interface OneToOne
This annotation also adds the @Transient and
@Value("null") annotations to the field.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether the orphan entity is preserved or not.Specifies the name of the "foreign key" column in the associated table.booleanWhether the associated entity are read-only or not, meaning it's never persisted or linked.
-
Element Details
-
keepOrphan
boolean keepOrphanWhether the orphan entity is preserved or not. Defaults tofalse.Usually, one-to-one relationships have a parent-child configuration, meaning the child needs to have the parent assigned to it. By default, the annotation will delete the associated entity when it becomes an orphan or the child is no longer assigned to the parent. You can prevent this behavior by setting this option to
true, in which case the annotation will only remove the link of the orphan entity with the parent.- Returns:
trueif orphan entities should be presereved,falseotherwise
- Default:
false
-
mappedBy
String mappedBySpecifies the name of the "foreign key" column in the associated table. This is optional because the annotation can infer the "foreign key" column name in two different ways:1. The column's name matches the parent table's name followed by an
_idsuffix.2. The column's name matches the name of the annotated field followed by an
_idsuffix.For example, given a parent table
phone, a child tabledetails, and the annotated field@OneToOne Details details;. The "foreign key" column of thedetailstable will be inferred as eitherphone_idusing option (1) or asdetails_idusing option (2).- Returns:
- the "foreign key" column name in the associated table
- Default:
""
-
readonly
boolean readonlyWhether the associated entity are read-only or not, meaning it's never persisted or linked. Defaults tofalse.- Returns:
trueif the associated entity is read-only,falseotherwise
- Default:
false
-