update javadoc for InsertGeneratedIdentifierDelegate

This commit is contained in:
Gavin 2022-12-02 15:07:29 +01:00 committed by Gavin King
parent 337919b766
commit 392b2f2364
1 changed files with 30 additions and 18 deletions

View File

@ -18,17 +18,29 @@ import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;
import org.hibernate.sql.model.ast.builder.TableInsertBuilder; import org.hibernate.sql.model.ast.builder.TableInsertBuilder;
/** /**
* Responsible for handling delegation relating to variants in how * Each implementation defines a strategy for retrieving a primary key
* insert-generated-identifier generator strategies dictate processing:<ul> * {@linkplain org.hibernate.tuple.InDatabaseGenerator generated by
* <li>building the sql insert statement * the database} from the database after execution of an {@code insert}
* <li>determination of the generated identifier value * statement. The generated primary key is usually an {@code IDENTITY}
* column, but in principle it might be something else, for example,
* a value generated by a trigger.
* <p>
* An implementation controls:
* <ul>
* <li>building the SQL {@code insert} statement, and
* <li>retrieving the generated identifier value using JDBC.
* </ul> * </ul>
* The implementation should be written to handle any instance of
* {@link org.hibernate.tuple.InDatabaseGenerator}.
*
* @see org.hibernate.tuple.InDatabaseGenerator
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface InsertGeneratedIdentifierDelegate { public interface InsertGeneratedIdentifierDelegate {
/** /**
* Create a TableInsertBuilder with any specific identity handling encoded * Create a {@link TableInsertBuilder} with any specific identity
* handling already built in.
*/ */
TableInsertBuilder createTableInsertBuilder( TableInsertBuilder createTableInsertBuilder(
BasicEntityIdentifierMapping identifierMapping, BasicEntityIdentifierMapping identifierMapping,
@ -38,7 +50,8 @@ public interface InsertGeneratedIdentifierDelegate {
PreparedStatement prepareStatement(String insertSql, SharedSessionContractImplementor session); PreparedStatement prepareStatement(String insertSql, SharedSessionContractImplementor session);
/** /**
* Perform the insert and extract the database-generated value * Perform the {@code insert} and extract the database-generated
* primary key value.
* *
* @see #createTableInsertBuilder * @see #createTableInsertBuilder
*/ */
@ -49,11 +62,11 @@ public interface InsertGeneratedIdentifierDelegate {
SharedSessionContractImplementor session); SharedSessionContractImplementor session);
/** /**
* Build a {@link org.hibernate.sql.Insert} specific to the delegate's mode * Build an {@linkplain org.hibernate.sql.Insert insert statement}
* of handling generated key values. * specific to the delegate's mode of handling generated key values.
* *
* @param context A context to help generate SQL strings * @param context A context to help generate SQL strings
* @return The insert object. * @return An {@link IdentifierGeneratingInsert}
* *
* @deprecated this is no longer called * @deprecated this is no longer called
*/ */
@ -61,25 +74,24 @@ public interface InsertGeneratedIdentifierDelegate {
IdentifierGeneratingInsert prepareIdentifierGeneratingInsert(SqlStringGenerationContext context); IdentifierGeneratingInsert prepareIdentifierGeneratingInsert(SqlStringGenerationContext context);
/** /**
* Append SQL specific to the delegate's mode * Append SQL specific to this delegate's mode of handling generated
* of handling generated key values. * primary key values to the given {@code insert} statement.
* *
* @return The insert SQL. * @return The processed {@code insert} statement string
*/ */
default String prepareIdentifierGeneratingInsert(String insertSQL) { default String prepareIdentifierGeneratingInsert(String insertSQL) {
return insertSQL; return insertSQL;
} }
/** /**
* Perform the indicated insert SQL statement and determine the identifier value * Execute the given {@code insert} statement and return the generated
* generated. * key value.
* *
* * @param insertSQL The {@code insert} statement string
* @param insertSQL The INSERT statement string
* @param session The session in which we are operating * @param session The session in which we are operating
* @param binder The param binder * @param binder The parameter binder
* *
* @return The generated identifier value. * @return The generated identifier value
*/ */
Object performInsert(String insertSQL, SharedSessionContractImplementor session, Binder binder); Object performInsert(String insertSQL, SharedSessionContractImplementor session, Binder binder);