java.lang.Object
org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
org.litebridge.db.spi.impl.sql.UpdateSqlGenerator
SQL generator for UPDATE statements.
-
Field Summary
Fields inherited from class org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
columnIdentifierGenerator, typeConverter -
Constructor Summary
ConstructorsConstructorDescriptionUpdateSqlGenerator(TypeConverter typeConverter, ColumnIdentifierGenerator columnIdentifierGenerator, BiFunction<Table, ConnectionProvider, TableMetaData> ensureTableMetaData) Creates a newUpdateSqlGenerator. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcreateMathOperation(ColumnMetaData column, MathOperation mathOperation) Creates a SQL representation of a math operation.prepareSql(Update update, ConnectionProvider connectionProvider) Prepare a SQL UPDATE statement along with its bind values for execution.Methods inherited from class org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
appendConditionsAndSubgroups, appendTable, appendTable, createBindValue, createCondition, ensureColumnMetaData, ensureTableMetaData, getExpressionValue, mapOperator
-
Constructor Details
-
UpdateSqlGenerator
public UpdateSqlGenerator(TypeConverter typeConverter, ColumnIdentifierGenerator columnIdentifierGenerator, BiFunction<Table, ConnectionProvider, TableMetaData> ensureTableMetaData) Creates a newUpdateSqlGenerator.- Parameters:
typeConverter- the type convertercolumnIdentifierGenerator- the column identifier generatorensureTableMetaData- a function to ensure table metadata
-
-
Method Details
-
prepareSql
Prepare a SQL UPDATE statement along with its bind values for execution.This method constructs the SQL query string based on the provided
Updateobject, which contains the table's metadata, column-value pairs, and conditions for the WHERE clause. It ensures proper formatting of the SQL query and converts values as needed using a type converter. The resulting SQL query and its associated bind values are encapsulated in aPreparedSqlobject.- Parameters:
update- theUpdateobject containing table metadata, column-value pairs for the SET clause, and conditions for the WHERE clause to specify target rows.connectionProvider- the connection provider- Returns:
- a
PreparedSqlobject containing the generated SQL query string and the list of bind values.
-
createMathOperation
Creates a SQL representation of a math operation.- Parameters:
column- the columnmathOperation- the math operation- Returns:
- the SQL representation of the math operation
-