clarify that @Generated does not always require a separate select statement

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-11-07 08:52:02 +01:00
parent 2eeb6153ff
commit c698b8a056
2 changed files with 17 additions and 4 deletions

View File

@ -17,8 +17,21 @@ import static org.hibernate.generator.EventType.INSERT;
/** /**
* Specifies that the value of the annotated property is generated by the * Specifies that the value of the annotated property is generated by the
* database. The generated value will be automatically retrieved using a * database. The generated value is automatically retrieved after it is
* SQL {@code select} after it is generated. * generated.
* <p>
* Retrieval of the generated value might require an additional SQL
* {@code select} statement, but this not necessary if:
* <ul>
* <li>
* the SQL dialect of the database
* {@linkplain org.hibernate.dialect.Dialect#supportsInsertReturning
* supports} {@code returning} or {@code select from final table}, or
* <li>
* the JDBC driver
* {@linkplain org.hibernate.dialect.Dialect#supportsInsertReturningGeneratedKeys
* provides} a similar capability via {@code getGeneratedKeys()}.
* </ul>
* <p> * <p>
* {@code @Generated} relieves the program of the need to explicitly call * {@code @Generated} relieves the program of the need to explicitly call
* {@link org.hibernate.Session#refresh(Object) refresh()} to synchronize * {@link org.hibernate.Session#refresh(Object) refresh()} to synchronize

View File

@ -4242,8 +4242,8 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
* <p> * <p>
* Support for identity columns is insufficient here, we require something like: * Support for identity columns is insufficient here, we require something like:
* <ol> * <ol>
* <li>{@code insert ... returning ...} * <li>{@code insert ... returning ...}, or
* <li>{@code select from final table (insert ... )} * <li>{@code select from final table (insert ... )}.
* </ol> * </ol>
* *
* @return {@code true} if {@link org.hibernate.id.insert.InsertReturningDelegate} * @return {@code true} if {@link org.hibernate.id.insert.InsertReturningDelegate}