Package org.assertj.db.type
Class Table
- All Implemented Interfaces:
DbElement,WithColumnLetterCase,WithLetterCase,WithPrimaryKeyLetterCase,WithTableLetterCase
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
Tablepoint to a table calledmoviein a H2 database in memory.AssertDbConnection connection = AssertDbConnectionFactory.of("jdbc:h2:mem:test", "sa", "").create(); Table table = connection.table("movie").build(); -
Below the
Tabletable1point to a table calledsong(but only on the columns callednumberandtitle).
And theTabletable2point to a table calledmusician(but ignore on the column calledbirthday).
TheAssertDbConnectionuse aDataSourceinstead 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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFluentTablebuilder.static classIndicates an order with the name on which is the order and the type. -
Field Summary
Fields inherited from class org.assertj.db.type.AbstractDbElement
myself -
Method Summary
Modifier and TypeMethodDescriptionString[]Returns the columns to check (which are present inAbstractDbData.getColumnsNameList()).String[]Returns the columns to exclude (which are not present inAbstractDbData.getColumnsNameList()).Returns the columns to order (which are used inORDER BY).Returns the end delimiter for column name and table name.getName()Return the name of the table.Returns the SQL request.Returns the start delimiter for column name and table name.protected voidloadImpl(Connection connection) Specific implementation of the loading for aTable.Methods inherited from class org.assertj.db.type.AbstractDbData
collectRowsFromResultSet, controlIfAllThePksNameExistInTheColumns, getColumn, getColumnsList, getColumnsNameList, getDataType, getPksNameList, getRow, getRowFromPksValues, getRowsList, setColumnsNameList, setPksNameList, sortRowsMethods inherited from class org.assertj.db.type.AbstractDbElement
getColumnLetterCase, getConnection, getConnectionProvider, getMetaData, getPrimaryKeyLetterCase, getTableLetterCase
-
Method Details
-
getName
Return the name of the table.- Returns:
- the name of the table.
- See Also:
-
getColumnsToCheck
Returns the columns to check (which are present inAbstractDbData.getColumnsNameList()).- Returns:
- Array of the name of the columns to check. If
nullthat means to check all the columns. - See Also:
-
getColumnsToExclude
Returns the columns to exclude (which are not present inAbstractDbData.getColumnsNameList()).- Returns:
- The columns.
- See Also:
-
getColumnsToOrder
Returns the columns to order (which are used inORDER BY).- Returns:
- Array of the name of the columns to order. If
nullthat means not to do order. - See Also:
-
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:
-
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:
-
getRequest
Returns the SQL request.- Specified by:
getRequestin classAbstractDbData<Table>- Returns:
- The SQL request.
- Throws:
NullPointerException- If thenamefield isnull.- See Also:
-
loadImpl
Specific implementation of the loading for aTable.- Specified by:
loadImplin classAbstractDbData<Table>- Parameters:
connection-Connectionto the database provided byAbstractDbData.load()private method.- Throws:
NullPointerException- If thenamefield isnull.SQLException- SQL Exception.- See Also:
-