Class UpdateQueryBuilder

java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.jdbc.dsl.QueryBuilder
io.github.blyznytsiaorg.bibernate.dao.jdbc.dsl.UpdateQueryBuilder

public class UpdateQueryBuilder extends QueryBuilder
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
  • Field Details

  • Constructor Details

    • UpdateQueryBuilder

      public UpdateQueryBuilder(String tableName)
      Constructs a new UpdateQueryBuilder with the specified table name.
      Parameters:
      tableName - The name of the table to be updated.
  • Method Details

    • update

      public static UpdateQueryBuilder update(String tableName)
      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

      public UpdateQueryBuilder setFieldIncrementVersion(String fieldName)
      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

      public UpdateQueryBuilder setField(String fieldName, Object value)
      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

      public UpdateQueryBuilder whereCondition(String condition)
      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

      public UpdateQueryBuilder andCondition(String condition)
      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

      public UpdateQueryBuilder orCondition(String condition)
      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

      public UpdateQueryBuilder betweenCondition(String field, Object lowerBound, Object upperBound)
      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

      public String 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.