mention that @NaturalId cannot be null in javadoc (#7370)

as in #7367
This commit is contained in:
Gavin King 2023-09-26 20:57:57 +02:00 committed by GitHub
parent 3b19661b2c
commit e7ad69d09c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -70,6 +70,11 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
* Unlike the {@linkplain jakarta.persistence.Id primary identifier}
* of an entity, a natural id may be {@linkplain #mutable}.
* <p>
* On the other hand, a field or property which forms part of a natural
* id may never be null, and so it's a good idea to use {@code @NaturalId}
* in conjunction with the Bean Validation {@code @NotNull} annotation
* or {@link jakarta.persistence.Basic#optional @Basic(optional=false)}.
* <p>
* The {@link org.hibernate.Session} interface offers several methods
* that allow an entity instance to be retrieved by its
* {@linkplain org.hibernate.Session#bySimpleNaturalId(Class) simple}
@ -78,12 +83,12 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
* NaturalIdCache natural id caching}, then these methods may be able
* to avoid a database round trip.
*
* @author Nicol<EFBFBD>s Lichtmaier
* @author Nicolás Lichtmaier
*
* @see NaturalIdCache
*/
@Target( { METHOD, FIELD } )
@Retention( RUNTIME )
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface NaturalId {
/**
* Specifies whether the natural id is mutable or immutable.