@@ -575,9 +575,9 @@ strategy hint has been specified. In particular, lazy fetching might
575
575
only be available for `Basic` mappings for which property-based access
576
576
is used.
577
577
578
- The `optional` element is a hint as to
579
- whether the value of the field or property may be null. It is
580
- disregarded for primitive types .
578
+ If the annotated field or property is of primitive type, or if it is
579
+ also annotated with `jakarta.annotation.Nonnull`, then `optional=false`
580
+ is implied, and the value of the `optional` annotation member is ignored .
581
581
582
582
.Basic Annotation Elements
583
583
[#a14218,options="header"]
@@ -590,9 +590,9 @@ strategy is a requirement on the persistence provider runtime that the
590
590
value must be eagerly fetched. The LAZY strategy is a hint to the
591
591
persistence provider runtime. |EAGER
592
592
|boolean |optional
593
- |(Optional) Whether the value of the field or
594
- property may be null. This is a hint and is disregarded for primitive
595
- types; it may be used in schema generation .
593
+ |(Optional) Whether the value of the field or property may be null.
594
+ May be used in schema generation. Ignored if the field or property
595
+ is of primitive type or is annotated `Nonnull` .
596
596
|true
597
597
|===
598
598
@@ -2983,6 +2983,10 @@ runtime that the associated entity should be fetched lazily when it is
2983
2983
first accessed. The implementation is permitted to eagerly fetch
2984
2984
associations for which the `LAZY` strategy hint has been specified.
2985
2985
2986
+ If the annotated field or property is also annotated with
2987
+ `jakarta.annotation.Nonnull`, then `optional=false` is implied
2988
+ and the value of the `optional` annotation member is ignored.
2989
+
2986
2990
.ManyToOne Annotation Elements
2987
2991
[#a15202,options="header"]
2988
2992
|===
@@ -3010,9 +3014,10 @@ persistence provider runtime.
3010
3014
3011
3015
|boolean
3012
3016
|optional
3013
- |(Optional) Whether the association is
3014
- optional. If set to false then a non-null relationship must always
3015
- exist.
3017
+ |(Optional) Whether the association is optional. If set to false,
3018
+ then a non-null relationship must always exist.
3019
+ May be used in schema generation. Ignored if the field or property
3020
+ is annotated `Nonnull`.
3016
3021
|true
3017
3022
|===
3018
3023
@@ -4118,6 +4123,10 @@ applications must otherwise not depend upon a specific order of removal,
4118
4123
and must not reassign an entity that has been orphaned to another
4119
4124
relationship or otherwise attempt to persist it.
4120
4125
4126
+ If the annotated field or property is also annotated with
4127
+ `jakarta.annotation.Nonnull`, then `optional=false` is implied
4128
+ and the value of the `optional` annotation member is ignored.
4129
+
4121
4130
.OneToOne Annotation Elements
4122
4131
[#a15735,options="header"]
4123
4132
|===
@@ -4144,9 +4153,10 @@ persistence provider runtime.
4144
4153
4145
4154
|boolean
4146
4155
|optional
4147
- |(Optional) Whether the association is
4148
- optional. If set to false then a non-null relationship must always
4149
- exist.
4156
+ |(Optional) Whether the association is optional. If set to false,
4157
+ then a non-null relationship must always exist.
4158
+ May be used in schema generation. Ignored if the field or property
4159
+ is annotated `Nonnull`.
4150
4160
|true
4151
4161
4152
4162
|String
0 commit comments