Class UpdateQueryBuilder
java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.jdbc.dsl.QueryBuilder
io.github.blyznytsiaorg.bibernate.dao.jdbc.dsl.UpdateQueryBuilder
Represents a SQL UPDATE query builder for constructing UPDATE statements with specified fields and conditions.
Extends the base class QueryBuilder.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents an individual field to be updated with its corresponding value. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private final List
<UpdateQueryBuilder.UpdateField> The list of fields to be updated with their corresponding values.Fields inherited from class io.github.blyznytsiaorg.bibernate.dao.jdbc.dsl.QueryBuilder
ALL_FIELDS, AND, AS, BETWEEN_S_AND_S, CLOSE_BRACKET, COMA, DELETE, DOT, EQ, FROM, GROUP_BY, HAVING, IN, INSERT_INTO, OPEN_BRACKET, OR, PARAMETER, SELECT, SEMICOLON, SET, SPACE, tableName, UNDERSCORE, UNION, UPDATE, WHERE, whereConditions
-
Constructor Summary
ConstructorsConstructorDescriptionUpdateQueryBuilder
(String tableName) Constructs a new UpdateQueryBuilder with the specified table name. -
Method Summary
Modifier and TypeMethodDescriptionandCondition
(String condition) Adds an AND condition to the existing WHERE conditions.betweenCondition
(String field, Object lowerBound, Object upperBound) Adds a BETWEEN condition to the existing WHERE conditions.Builds the UPDATE SQL statement based on the configured fields and conditions.orCondition
(String condition) Adds an OR condition to the existing WHERE conditions.Adds a field to be updated with the specified value.setFieldIncrementVersion
(String fieldName) Adds a field to be updated with an incremented value.static UpdateQueryBuilder
Creates a new UpdateQueryBuilder with the specified table name.whereCondition
(String condition) Adds a WHERE condition to the UPDATE statement.Methods inherited from class io.github.blyznytsiaorg.bibernate.dao.jdbc.dsl.QueryBuilder
handleWhereCondition
-
Field Details
-
ONE
- See Also:
-
PLUS
- See Also:
-
updateFields
The list of fields to be updated with their corresponding values.
-
-
Constructor Details
-
UpdateQueryBuilder
Constructs a new UpdateQueryBuilder with the specified table name.- Parameters:
tableName
- The name of the table to be updated.
-
-
Method Details
-
update
Creates a new UpdateQueryBuilder with the specified table name.- Parameters:
tableName
- The name of the table to be updated.- Returns:
- A new instance of UpdateQueryBuilder.
-
setFieldIncrementVersion
Adds a field to be updated with an incremented value. Useful for versioning fields, e.g., setFieldIncrementVersion("version").- Parameters:
fieldName
- The name of the field to be updated.- Returns:
- The current UpdateQueryBuilder instance for method chaining.
-
setField
Adds a field to be updated with the specified value.- Parameters:
fieldName
- The name of the field to be updated.value
- The new value for the field.- Returns:
- The current UpdateQueryBuilder instance for method chaining.
-
whereCondition
Adds a WHERE condition to the UPDATE statement.- Parameters:
condition
- The WHERE condition to be added.- Returns:
- The current UpdateQueryBuilder instance for method chaining.
-
andCondition
Adds an AND condition to the existing WHERE conditions.- Parameters:
condition
- The AND condition to be added.- Returns:
- The current UpdateQueryBuilder instance for method chaining.
-
orCondition
Adds an OR condition to the existing WHERE conditions.- Parameters:
condition
- The OR condition to be added.- Returns:
- The current UpdateQueryBuilder instance for method chaining.
-
betweenCondition
Adds a BETWEEN condition to the existing WHERE conditions.- Parameters:
field
- The field to which the BETWEEN condition applies.lowerBound
- The lower bound of the range.upperBound
- The upper bound of the range.- Returns:
- The current UpdateQueryBuilder instance for method chaining.
-
buildUpdateStatement
Builds the UPDATE SQL statement based on the configured fields and conditions.- Returns:
- The generated UPDATE SQL statement as a string.
- Throws:
IllegalStateException
- If no fields are specified for update.
-