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
* database. The generated value will be automatically retrieved using a
* SQL {@code select} after it is generated.
* database. The generated value is automatically retrieved after it is
* 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>
* {@code @Generated} relieves the program of the need to explicitly call
* {@link org.hibernate.Session#refresh(Object) refresh()} to synchronize

View File

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