Class Table

All Implemented Interfaces:
DbElement, WithColumnLetterCase, WithLetterCase, WithPrimaryKeyLetterCase, WithTableLetterCase

public class Table extends AbstractDbData<Table>
A table in the database to read to get the values.

The different information of the table are name of the table and optionally the columns to check and to exclude. A table should be constructed by the fluent builder Table.Builder from a AssertDbConnection instance.

Examples of instantiation :

  • This Table point to a table called movie in a H2 database in memory.

     
     AssertDbConnection connection = AssertDbConnectionFactory.of("jdbc:h2:mem:test", "sa", "").create();
     Table table = connection.table("movie").build();
     
     
  • Below the Table table1 point to a table called song (but only on the columns called number and title).
    And the Table table2 point to a table called musician (but ignore on the column called birthday).
    The AssertDbConnection use a DataSource instead of a JDBC url like above.

     
     DataSource dataSource = ...;
     AssertDbConnection connection = AssertDbConnectionFactory.of(dataSource).create();
     Table table1 = connection.table("song").columnsToCheck(new String[] { "number", "title" }).build();
     Table table2 = connection..table("musician").columnsToExclude(new String[] { "birthday" }).build();
     
     
Author:
Régis Pouiller, Julien Roy
  • Method Details

    • getName

      public String getName()
      Return the name of the table.
      Returns:
      the name of the table.
      See Also:
      • setName(String)
    • getColumnsToCheck

      public String[] getColumnsToCheck()
      Returns the columns to check (which are present in AbstractDbData.getColumnsNameList()).
      Returns:
      Array of the name of the columns to check. If null that means to check all the columns.
      See Also:
      • setColumnsToCheck(String[])
    • getColumnsToExclude

      public String[] getColumnsToExclude()
      Returns the columns to exclude (which are not present in AbstractDbData.getColumnsNameList()).
      Returns:
      The columns.
      See Also:
      • setColumnsToExclude(String[])
    • getColumnsToOrder

      public Table.Order[] getColumnsToOrder()
      Returns the columns to order (which are used in ORDER BY).
      Returns:
      Array of the name of the columns to order. If null that means not to do order.
      See Also:
      • setColumnsToOrder(Order[])
    • getStartDelimiter

      public Character getStartDelimiter()
      Returns the start delimiter for column name and table name.
      Returns:
      The start delimiter for column name and table name.
      Since:
      1.2.0
      See Also:
      • setStartDelimiter(Character)
    • getEndDelimiter

      public Character getEndDelimiter()
      Returns the end delimiter for column name and table name.
      Returns:
      The end delimiter for column name and table name.
      Since:
      1.2.0
      See Also:
      • setEndDelimiter(Character)
    • getRequest

      public String getRequest()
      Returns the SQL request.
      Specified by:
      getRequest in class AbstractDbData<Table>
      Returns:
      The SQL request.
      Throws:
      NullPointerException - If the name field is null.
      See Also:
    • loadImpl

      protected void loadImpl(Connection connection) throws SQLException
      Specific implementation of the loading for a Table.
      Specified by:
      loadImpl in class AbstractDbData<Table>
      Parameters:
      connection - Connection to the database provided by AbstractDbData.load() private method.
      Throws:
      NullPointerException - If the name field is null.
      SQLException - SQL Exception.
      See Also: