Hitachi

uCosminexus Application Server Compatibility Guide


8.12.37 @OneToOne

Organization of this subsection

(1) Description

This annotation indicates that the specified class has OneToOne relationship, and also specifies the single relationship between entity classes.

Furthermore, to achieve a bi-directional relationship, always specify the mappedBy element at the non-owner side.

The applicable targets are method and field.

(2) Element

The following table lists the elements of @OneToOne:

Element name

Optional/Required

Element description

targetEntity

Optional

This element specifies the non-owner entity class.

cascade

Optional

This element specifies the operations to be cascaded.

fetch

Optional

This element specifies the specification value of the fetch strategy.

optional

Optional

This element specifies whether or not a null value can be set up for all non-primitive type fields and properties.

mappedBy

Optional

This element specifies the name of the field that maintains a relationship in the owner entity class, when added in the elements of the non-owner entity class.

The details of attributes that are supported with Cosminexus JPA provider are as follows:

(a) targetEntity element

Type

Class

Description

This element specifies the non-owner entity class.

Default value

Type of the field and property in which the annotation is added

(b) cascade element

Type

CascadeType[]

Description

This element specifies the operations to be cascaded.

The following table describes the specifiable values:

  • CascadeType.ALL: The persist, remove, merge, and refresh operations of the owner entity class are cascaded to the related destination.

  • CascadeType.MERGE: The merge operation of the owner entity class is cascaded to the related destination.

  • CascadeType.PERSIST: The persist operation of the owner entity class is cascaded to the related destination.

  • CascadeType.REFRESH: The refresh operation of the owner entity class is cascaded to the related destination.

  • CascadeType.REMOVE: The remove operation of the owner entity class is cascaded to the related destination.

Default value

Not to be cascaded

(c) fetch element

Type

FetchType

Description

This attribute defines the fetch strategy of data from the database. For details on the fetch strategy, see 9.4.5 Synchronization with the database.

The following two types of values can be specified:

  • EAGER strategy: Requests in which the data must be fetched eagerly

  • LAZY strategy: Requests in which data is fetched lazily when accessed for the first time

Default value

FetchType.EAGER

(d) optional element

Type

boolean

Description

This element specifies whether or not a null value can be set up for all non-primitive type fields and properties. The following values can be specified:

  • true: A null value can be set up for all non-primitive type fields and properties.

  • false: A null value cannot be specified for all non-primitive type fields and properties.

Default value

true

(e) mappedBy element

Type

String

Description

This element specifies the name of the field that maintains a relationship in the owner entity class, when added in the elements of the non-owner entity class. When this element is specified, the relationship becomes bi-directional.

Default value

None