Class WbsTable

java.lang.Object
wbs.utils.util.database.WbsTable

public class WbsTable extends Object
  • Constructor Details

  • Method Details

    • addField

      public void addField(WbsField... field)
    • removeField

      public boolean removeField(WbsField field)
    • addNewField

      public boolean addNewField(WbsField field)
      Add a new field, updating the underlying database.
      Parameters:
      field - The field to add
      Returns:
      True if the field was added successfully, or false if the field failed to add for any reason.
    • addFieldIfNotExists

      public boolean addFieldIfNotExists(WbsField field)
      Adds a field if it doesn't already exist.
      Parameters:
      field - The field to try adding.
      Returns:
      True if the field now exists, regardless of if it existed previously. False if there was an error.
    • updateField

      public boolean updateField(WbsField field)
      Update the definition of a field.
      Note that this change is potentially destructive, as it require
      Parameters:
      field - The field to update
      Returns:
      True if the field was updated (or already existed as-is), false if an error occurred or if the field didn't exist to be updated
    • getCreationQuery

      public String getCreationQuery()
    • getInsertStatement

      public String getInsertStatement()
    • getInsertStatement

      public String getInsertStatement(int amount)
    • getUpdateStatement

      public String getUpdateStatement(@NotNull @NotNull String whereClaus)
    • selectOnField

      @NotNull public @NotNull List<WbsRecord> selectOnField(@NotNull @NotNull WbsField field, @Nullable @Nullable Object match)
    • selectOnField

      @NotNull public @NotNull List<WbsRecord> selectOnField(@NotNull @NotNull WbsField field, @Nullable @Nullable Object match, @Nullable @Nullable CollateFunction collate)
    • selectOnFields

      @NotNull public @NotNull List<WbsRecord> selectOnFields(Collection<WbsField> fields, Collection<?> matches)
    • upsert

      public boolean upsert(List<WbsRecord> records)
      Inserts the given map of objects.
      Parameters:
      records - The record to insert, with all fields populated.
      Returns:
      True if the upsert was successful, false if any key was missing or no records were provided
    • insert

      public boolean insert(List<WbsRecord> records)
      Inserts the given map of objects.
      Parameters:
      records - The record to insert, with all fields populated.
      Returns:
      True if the insert was successful, false if any key was missing or no records were provided
    • insert

      public boolean insert(List<WbsRecord> records, Connection connection) throws WbsDatabaseException
      Throws:
      WbsDatabaseException
    • update

      public boolean update(List<WbsRecord> records)
    • update

      public boolean update(List<WbsRecord> records, String whereClause)
      Updates the given list of records using the provided whereClause.
      Parameters:
      records - The records to update, with all fields populated.
      whereClause - The where condition to update on, with fields populated for each record individually, in the same order as the fields are declared on the table. To use complex conditions that use fields in another order, or more than once, perform a direct query.
      Returns:
      True if the update was successful, false if any key was missing or no records were provided.
    • update

      public boolean update(List<WbsRecord> records, Connection connection, String whereClause) throws WbsDatabaseException
      Updates the given list of records using the provided whereClause. The given connection is not closed, allowing for batching.
      Parameters:
      records - The records to update, with all fields populated.
      connection - The connection to use for all queries performed.
      whereClause - The where condition to update on, with fields populated for each record individually, in the same order as the fields are declared on the table. To use complex conditions that use fields in another order, or more than once, perform a direct query.
      Returns:
      True if the update was successful, false if any key was missing or no records were provided.
      Throws:
      WbsDatabaseException
    • update

      public boolean update(WbsRecord record, Connection connection, String whereClause) throws WbsDatabaseException
      Performs an update using a single record for the fields, using the given where clause. The given connection is not closed, allowing for batching.
      Parameters:
      record - The records to update, with all fields populated.
      connection - The connection to use for all queries performed.
      whereClause - The where condition to update on, with fields populated for each record individually, in the same order as the fields are declared on the table. To use complex conditions that use fields in another order, or more than once, perform a direct query.
      Returns:
      True if the update was successful, false if any key was missing or no records were provided.
      Throws:
      WbsDatabaseException
    • getName

      public String getName()
    • getSelectQuery

      public String getSelectQuery(String whereClause)
    • getSelectQuery

      public String getSelectQuery(String fields, String whereClause)
    • getField

      @Nullable public @Nullable WbsField getField(String fieldName)
    • getPrimaryKeyQuery

      public String getPrimaryKeyQuery()
    • getPrimaryKeys

      public List<WbsField> getPrimaryKeys()
    • getFields

      public List<WbsField> getFields()
    • inDebugMode

      public boolean inDebugMode()
    • setDebugMode

      public void setDebugMode(boolean debugMode)