2.7.29 @ManyToOne

Organization of this subsection
(1) Description
(2) Element

(1) Description

This annotation indicates that the class in which @ManyToOne is specified has a ManyToOne relationship, and also specifies the relationship from the owner entity class to the non--owner entity class.

The applicable targets are method and field.

(2) Element

The following table lists the elements of @ManyToOne:

Element nameOptional/RequiredElement description
targetEntityOptionalThis element specifies the non-owner entity class.
cascadeOptionalThis element specifies the operations to be cascaded.
fetchOptionalThis element specifies the specification value of the fetch strategy.
optionalOptionalThis element specifies whether or not a null value can be set up for all non--primitive type fields and properties.

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 6.4.5 Synchronization with the database in the uCosminexus Application Server Common Container Functionality Guide.
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