Interface Table<R>

All Superinterfaces:
AutoCloseable, Closeable

public interface Table<R> extends Closeable
Defines a relational collection of persistent rows. A row is defined by an interface consisting of accessor/mutator methods corresponding to each column:
@PrimaryKey("id")
public interface MyRow {
    long id();
    void id(long id);

    String name();
    void name(String str);

    String message();
    void message(String str);
}

Supported column types:

  • Simple objects — String, BigInteger, and BigDecimal
  • Primitives — int, double, etc
  • Boxed primitives — Integer, Double, etc
  • Primitive arrays — int[], double[], etc
By default, object columns cannot be set to null, and attempting to do so causes an IllegalArgumentException to be thrown. The column definition must be annotated with @Nullable to support nulls.

The actual row implementation class is generated at runtime, and the standard equals, hashCode, toString, and clone methods are automatically generated as well. If the row interface declares a clone method which returns the exact row type, then the row can be cloned without requiring an explicit cast. If the row interface extends Comparable, then rows are comparable by primary key. Any default methods defined in the row interface are never overridden by the generated class, unless the method is defined in the Object class.

Scans over the rows of the table can be reduced by a query, described by this syntax:


 Query        = RowFilter
              | Projection [ RowFilter ]
 RowFilter    = AndFilter { "||" AndFilter }
 AndFilter    = EntityFilter { "&&" EntityFilter }
 EntityFilter = ColumnFilter | ParenFilter
 ParenFilter  = [ "!" ] "(" [ RowFilter ] ")"
 ColumnFilter = ColumnName RelOp ( ArgRef | ColumnName )
              | ColumnName "in" ArgRef
              | ArgRef RelOp ColumnName
 RelOp        = "==" | "!=" | ">=" | "<" | "<=" | ">"
 Projection   = "{" ProjColumns "}"
 ProjColumns  = [ ProjColumn { "," ProjColumn } ]
 ProjColumn   = ( ( ( ( "+" | "-" ) [ "!" ] ) | "~" ) ColumnName ) | "*"
 ColumnName   = string
 ArgRef       = "?" [ uint ]
 
Note that a query projection specifies the minimum set of requested columns, but additional ones might be provided if they were needed by the query implementation.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default <T> Table<T>
    aggregate(Class<T> targetType, Aggregator.Factory<R,T> factory)
    Returns a view backed by this table, consisting of aggregate rows, which are grouped by the primary key of the target type.
    default boolean
    Returns true if any rows exist in this table.
    default boolean
    anyRows(Transaction txn, String query, Object... args)
    Returns true if a subset of rows from this table exists, as specified by the query expression.
    default boolean
    anyRows(R row, Transaction txn, String query, Object... args)
    Returns true if a subset of rows from this table exists, as specified by the query expression.
    void
    cleanRow(R row)
    Sets columns which have a dirty state to clean.
    cloneRow(R row)
    Returns a new row instance which is an exact copy of the given row.
    void
     
    default Comparator<R>
    Returns a row comparator based on the given specification, which defines the ordering columns.
    static <T> Table<T>
    concat(Class<T> targetType, Table<?>... sources)
    Returns a view consisting of all rows from the given source tables concatenated together, possibly resulting in duplicate rows.
    static Table<Row>
    concat(Table<?>... sources)
    Returns a view consisting of all rows from the given source tables concatenated together, possibly resulting in duplicate rows.
    void
    copyRow(R from, R to)
    Copies all columns and states from one row to another.
    default void
    delete(Transaction txn, R row)
    Unconditionally removes an existing row by primary key.
    <D> Table<D>
    derive(Class<D> derivedType, String query, Object... args)
    Returns a view backed by this table, specified by a fully-featured query expression.
    derive(String query, Object... args)
    Returns a view backed by this table, specified by a fully-featured query expression.
    Returns a view of this table which has duplicate rows filtered out.
    default R
    exchange(Transaction txn, R row)
    Unconditionally stores the given row, potentially replacing a corresponding row which already exists.
    boolean
    exists(Transaction txn, R row)
    Checks if a row exists by searching against the primary key.
    void
    forEach(R row, ColumnProcessor<? super R> action)
    For the given row, performs an action for each column which is set.
    default <T> Table<T>
    group(String groupBy, String orderBy, Class<T> targetType, Grouper.Factory<R,T> factory)
    Returns a view backed by this table, which processes groups of source rows into groups of target rows.
    boolean
    Returns true if this table has a primary key defined, as specified by the row type.
    default void
    insert(Transaction txn, R row)
    Stores the given row when a corresponding row doesn't exist.
    boolean
     
    boolean
    Non-transactionally determines if the table has nothing in it.
    boolean
    isSet(R row, String name)
    Returns true if the given row column is set.
    static Table<Row>
    Returns an unmodifiable table consisting of one row with no columns, representing the identity element when joining an empty set of tables.
    static <J> Table<J>
    join(Class<J> joinType, String spec, Table<?>... tables)
    Joins tables together into an unmodifiable view.
    static Table<Row>
    join(String spec, Table<?>... tables)
    Joins tables together into a generated join type class.
    default void
    load(Transaction txn, R row)
    Fully loads the row by primary key.
    default <T> Table<T>
    map(Class<T> targetType)
    Returns a view backed by this table, whose rows have been mapped to target rows, applying any necessary column value conversions.
    default <T> Table<T>
    map(Class<T> targetType, Mapper<R,T> mapper)
    Returns a view backed by this table, whose rows have been mapped to target rows.
    default void
    merge(Transaction txn, R row)
    Updates an existing row with the modified columns of the given row, and then loads the result back into the given row.
    Returns a new row instance with unset columns.
    default Scanner<R>
    Returns a new scanner for all rows of this table.
    default Scanner<R>
    newScanner(Transaction txn, String query, Object... args)
    Returns a new scanner for a subset of rows from this table, as specified by the query expression.
    Returns a new scanner for all rows of this table.
    default Scanner<R>
    newScanner(R row, Transaction txn, String query, Object... args)
    Returns a new scanner for a subset of rows from this table, as specified by the query expression.
    default Stream<R>
    Returns a new stream for all rows of this table.
    default Stream<R>
    newStream(Transaction txn, String query, Object... args)
    Returns a new stream for a subset of rows from this table, as specified by the query expression.
    Returns a new transaction which is compatible with this table.
    default Updater<R>
    Returns a new updater for all rows of this table.
    default Updater<R>
    newUpdater(Transaction txn, String query, Object... args)
    Returns a new updater for a subset of rows from this table, as specified by the query expression.
    default Updater<R>
    Returns a new updater for all rows of this table.
    default Updater<R>
    newUpdater(R row, Transaction txn, String query, Object... args)
    Returns a new updater for a subset of rows from this table, as specified by the query expression.
    default Predicate<R>
    predicate(String query, Object... args)
    Returns a row predicate for the given query expression and arguments.
    query(String query)
    Returns a query for a subset of rows from this table, as specified by the query expression.
    default Query<R>
    Returns a query for all rows of this table.
    default void
    replace(Transaction txn, R row)
    Stores the given row when a corresponding row already exists.
    Returns the interface which defines the rows of this table.
    default void
    store(Transaction txn, R row)
    Unconditionally stores the given row, potentially replacing a corresponding row which already exists.
    default boolean
    tryDelete(Transaction txn, R row)
    Unconditionally removes an existing row by primary key.
    default boolean
    tryInsert(Transaction txn, R row)
    Stores the given row when a corresponding row doesn't exist.
    boolean
    tryLoad(Transaction txn, R row)
    Fully loads the row by primary key.
    default boolean
    tryMerge(Transaction txn, R row)
    Updates an existing row with the modified columns of the given row, and then loads the result back into the given row.
    default boolean
    Stores the given row when a corresponding row already exists.
    default boolean
    tryUpdate(Transaction txn, R row)
    Updates an existing row with the modified columns of the given row, but the resulting row isn't loaded back.
    void
    unsetRow(R row)
    Resets the state of the given row such that all columns are unset.
    default void
    update(Transaction txn, R row)
    Updates an existing row with the modified columns of the given row, but the resulting row isn't loaded back.
  • Method Details

    • hasPrimaryKey

      boolean hasPrimaryKey()
      Returns true if this table has a primary key defined, as specified by the row type.
    • rowType

      Class<R> rowType()
      Returns the interface which defines the rows of this table.
    • newRow

      R newRow()
      Returns a new row instance with unset columns.
    • cloneRow

      R cloneRow(R row)
      Returns a new row instance which is an exact copy of the given row.
    • unsetRow

      void unsetRow(R row)
      Resets the state of the given row such that all columns are unset.
    • cleanRow

      void cleanRow(R row)
      Sets columns which have a dirty state to clean. All unset columns remain unset.
    • copyRow

      void copyRow(R from, R to)
      Copies all columns and states from one row to another.
    • isSet

      boolean isSet(R row, String name)
      Returns true if the given row column is set.
      Throws:
      IllegalArgumentException - if column is unknown
    • forEach

      void forEach(R row, ColumnProcessor<? super R> action)
      For the given row, performs an action for each column which is set.
    • newScanner

      default Scanner<R> newScanner(Transaction txn) throws IOException
      Returns a new scanner for all rows of this table.
      Parameters:
      txn - optional transaction for the scanner to use; pass null for auto-commit mode
      Returns:
      a new scanner positioned at the first row in the table
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • newScanner

      Scanner<R> newScanner(R row, Transaction txn) throws IOException
      Returns a new scanner for all rows of this table.
      Parameters:
      row - row instance for the scanner to use; pass null to create a new instance
      txn - optional transaction for the scanner to use; pass null for auto-commit mode
      Returns:
      a new scanner positioned at the first row in the table
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • newScanner

      default Scanner<R> newScanner(Transaction txn, String query, Object... args) throws IOException
      Returns a new scanner for a subset of rows from this table, as specified by the query expression.
      Parameters:
      txn - optional transaction for the scanner to use; pass null for auto-commit mode
      Returns:
      a new scanner positioned at the first row in the table accepted by the query
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • newScanner

      default Scanner<R> newScanner(R row, Transaction txn, String query, Object... args) throws IOException
      Returns a new scanner for a subset of rows from this table, as specified by the query expression.
      Parameters:
      row - row instance for the scanner to use; pass null to create a new instance
      txn - optional transaction for the scanner to use; pass null for auto-commit mode
      Returns:
      a new scanner positioned at the first row in the table accepted by the query
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • newUpdater

      default Updater<R> newUpdater(Transaction txn) throws IOException
      Returns a new updater for all rows of this table.

      When providing a transaction which acquires locks (or the transaction is null), upgradable locks are acquired for each row visited by the updater. If the transaction lock mode is non-repeatable, any lock acquisitions for rows which are stepped over are released when moving to the next row. Updates with a null transaction are auto-committed and become visible to other transactions as the updater moves along.

      Parameters:
      txn - optional transaction for the updater to use; pass null for auto-commit mode
      Returns:
      a new updater positioned at the first row in the table
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • newUpdater

      default Updater<R> newUpdater(R row, Transaction txn) throws IOException
      Returns a new updater for all rows of this table.

      When providing a transaction which acquires locks (or the transaction is null), upgradable locks are acquired for each row visited by the updater. If the transaction lock mode is non-repeatable, any lock acquisitions for rows which are stepped over are released when moving to the next row. Updates with a null transaction are auto-committed and become visible to other transactions as the updater moves along.

      Parameters:
      row - row instance for the updater to use; pass null to create a new instance
      txn - optional transaction for the updater to use; pass null for auto-commit mode
      Returns:
      a new updater positioned at the first row in the table
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • newUpdater

      default Updater<R> newUpdater(Transaction txn, String query, Object... args) throws IOException
      Returns a new updater for a subset of rows from this table, as specified by the query expression.

      When providing a transaction which acquires locks (or the transaction is null), upgradable locks are acquired for each row visited by the updater. If the transaction lock mode is non-repeatable, any lock acquisitions for rows which are stepped over are released when moving to the next row. Updates with a null transaction are auto-committed and become visible to other transactions as the updater moves along.

      Parameters:
      txn - optional transaction for the updater to use; pass null for auto-commit mode
      Returns:
      a new updater positioned at the first row in the table accepted by the query
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • newUpdater

      default Updater<R> newUpdater(R row, Transaction txn, String query, Object... args) throws IOException
      Returns a new updater for a subset of rows from this table, as specified by the query expression.

      When providing a transaction which acquires locks (or the transaction is null), upgradable locks are acquired for each row visited by the updater. If the transaction lock mode is non-repeatable, any lock acquisitions for rows which are stepped over are released when moving to the next row. Updates with a null transaction are auto-committed and become visible to other transactions as the updater moves along.

      Parameters:
      row - row instance for the updater to use; pass null to create a new instance
      txn - optional transaction for the updater to use; pass null for auto-commit mode
      Returns:
      a new updater positioned at the first row in the table accepted by the query
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • newStream

      default Stream<R> newStream(Transaction txn)
      Returns a new stream for all rows of this table. The stream must be explicitly closed when no longer used, or else it must be used with a try-with-resources statement. If an underlying IOException is generated, it's thrown as if it was unchecked.
      Parameters:
      txn - optional transaction for the stream to use; pass null for auto-commit mode
      Returns:
      a new stream positioned at the first row in the table
      Throws:
      IllegalStateException - if transaction belongs to another database instance
    • newStream

      default Stream<R> newStream(Transaction txn, String query, Object... args)
      Returns a new stream for a subset of rows from this table, as specified by the query expression. The stream must be explicitly closed when no longer used, or else it must be used with a try-with-resources statement. If an underlying IOException is generated, it's thrown as if it was unchecked.
      Parameters:
      txn - optional transaction for the stream to use; pass null for auto-commit mode
      Returns:
      a new stream positioned at the first row in the table accepted by the query
      Throws:
      IllegalStateException - if transaction belongs to another database instance
    • query

      Query<R> query(String query) throws IOException
      Returns a query for a subset of rows from this table, as specified by the query expression.
      Throws:
      IOException
    • queryAll

      default Query<R> queryAll() throws IOException
      Returns a query for all rows of this table.
      Throws:
      IOException
    • anyRows

      default boolean anyRows(Transaction txn) throws IOException
      Returns true if any rows exist in this table.
      Parameters:
      txn - optional transaction to use; pass null for auto-commit mode
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
      See Also:
    • anyRows

      default boolean anyRows(Transaction txn, String query, Object... args) throws IOException
      Returns true if a subset of rows from this table exists, as specified by the query expression.
      Parameters:
      txn - optional transaction to use; pass null for auto-commit mode
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • anyRows

      default boolean anyRows(R row, Transaction txn, String query, Object... args) throws IOException
      Returns true if a subset of rows from this table exists, as specified by the query expression.
      Parameters:
      row - row instance for the implementation to use; pass null to create a new instance if necessary
      txn - optional transaction to use; pass null for auto-commit mode
      Throws:
      IllegalStateException - if transaction belongs to another database instance
      IOException
    • newTransaction

      Transaction newTransaction(DurabilityMode durabilityMode)
      Returns a new transaction which is compatible with this table. If the provided durability mode is null, a default mode is selected.
    • isEmpty

      boolean isEmpty() throws IOException
      Non-transactionally determines if the table has nothing in it. A return value of true guarantees that the table is empty, but false negatives are possible.
      Throws:
      IOException
      See Also:
    • load

      default void load(Transaction txn, R row) throws IOException
      Fully loads the row by primary key.
      Throws:
      IllegalStateException - if primary key isn't fully specified
      NoSuchRowException - if a corresponding row doesn't exist
      IOException
    • tryLoad

      boolean tryLoad(Transaction txn, R row) throws IOException
      Fully loads the row by primary key.
      Returns:
      false if a corresponding row doesn't exist
      Throws:
      IllegalStateException - if primary key isn't fully specified
      IOException
    • exists

      boolean exists(Transaction txn, R row) throws IOException
      Checks if a row exists by searching against the primary key. This method should be called only if the row doesn't need to be loaded or stored — calling exists and then calling a load or store method is typically less efficient than skipping the exists check entirely.
      Returns:
      false if a corresponding row doesn't exist
      Throws:
      IllegalStateException - if primary key isn't fully specified
      IOException
    • store

      default void store(Transaction txn, R row) throws IOException
      Unconditionally stores the given row, potentially replacing a corresponding row which already exists.
      Throws:
      IllegalStateException - if any required columns aren't set
      UniqueConstraintException - if a conflicting alternate key exists
      IOException
    • exchange

      default R exchange(Transaction txn, R row) throws IOException
      Unconditionally stores the given row, potentially replacing a corresponding row which already exists.
      Returns:
      a copy of the replaced row, or null if none existed
      Throws:
      IllegalStateException - if any required columns aren't set
      UniqueConstraintException - if a conflicting alternate key exists
      IOException
    • insert

      default void insert(Transaction txn, R row) throws IOException
      Stores the given row when a corresponding row doesn't exist.
      Throws:
      IllegalStateException - if any required columns aren't set
      UniqueConstraintException - if a conflicting primary or alternate key exists
      IOException
    • tryInsert

      default boolean tryInsert(Transaction txn, R row) throws IOException
      Stores the given row when a corresponding row doesn't exist.
      Returns:
      false if a corresponding row already exists and nothing was inserted
      Throws:
      IllegalStateException - if any required columns aren't set
      UniqueConstraintException - if a conflicting alternate key exists
      IOException
    • replace

      default void replace(Transaction txn, R row) throws IOException
      Stores the given row when a corresponding row already exists.
      Throws:
      IllegalStateException - if any required columns aren't set
      NoSuchRowException - if a corresponding row doesn't exist
      UniqueConstraintException - if a conflicting alternate key exists
      IOException
    • tryReplace

      default boolean tryReplace(Transaction txn, R row) throws IOException
      Stores the given row when a corresponding row already exists.
      Returns:
      false if a corresponding row doesn't exist
      Throws:
      IllegalStateException - if any required columns aren't set
      UniqueConstraintException - if a conflicting alternate key exists
      IOException
    • update

      default void update(Transaction txn, R row) throws IOException
      Updates an existing row with the modified columns of the given row, but the resulting row isn't loaded back.
      Throws:
      IllegalStateException - if primary key isn't fully specified
      NoSuchRowException - if a corresponding row doesn't exist
      UniqueConstraintException - if a conflicting alternate key exists
      IOException
    • tryUpdate

      default boolean tryUpdate(Transaction txn, R row) throws IOException
      Updates an existing row with the modified columns of the given row, but the resulting row isn't loaded back.
      Returns:
      false if a corresponding row doesn't exist
      Throws:
      IllegalStateException - if primary key isn't fully specified
      UniqueConstraintException - if a conflicting alternate key exists
      IOException
    • merge

      default void merge(Transaction txn, R row) throws IOException
      Updates an existing row with the modified columns of the given row, and then loads the result back into the given row.
      Throws:
      IllegalStateException - if primary key isn't fully specified
      NoSuchRowException - if a corresponding row doesn't exist
      UniqueConstraintException - if a conflicting alternate key exists
      IOException
    • tryMerge

      default boolean tryMerge(Transaction txn, R row) throws IOException
      Updates an existing row with the modified columns of the given row, and then loads the result back into the given row.
      Returns:
      false if a corresponding row doesn't exist
      Throws:
      IllegalStateException - if primary key isn't fully specified
      UniqueConstraintException - if a conflicting alternate key exists
      IOException
    • delete

      default void delete(Transaction txn, R row) throws IOException
      Unconditionally removes an existing row by primary key.
      Throws:
      IllegalStateException - if primary key isn't fully specified
      NoSuchRowException - if a corresponding row doesn't exist
      IOException
    • tryDelete

      default boolean tryDelete(Transaction txn, R row) throws IOException
      Unconditionally removes an existing row by primary key.
      Returns:
      false if a corresponding row doesn't exist
      Throws:
      IllegalStateException - if primary key isn't fully specified
      IOException
    • map

      default <T> Table<T> map(Class<T> targetType, Mapper<R,T> mapper) throws IOException
      Returns a view backed by this table, whose rows have been mapped to target rows. The returned table instance will throw a ViewConstraintException for operations against rows not supported by the mapper, and closing the table has no effect.
      Throws:
      NullPointerException - if any parameter is null
      IOException
    • map

      default <T> Table<T> map(Class<T> targetType) throws IOException
      Returns a view backed by this table, whose rows have been mapped to target rows, applying any necessary column value conversions. The returned table instance will throw a ConversionException for operations against rows which cannot be converted back source rows, and closing the table has no effect.

      Source column values are converted to target column values using a potentially lossy conversion, which can cause numbers to be clamped to a narrower range, etc. Columns which aren't mapped to the target are dropped, and columns which don't map from the source are set to the most appropriate default value, preferably null.

      Parameters:
      targetType - target row type; the primary key is possibly ignored
      Throws:
      NullPointerException - if any parameter is null
      IOException
    • aggregate

      default <T> Table<T> aggregate(Class<T> targetType, Aggregator.Factory<R,T> factory) throws IOException
      Returns a view backed by this table, consisting of aggregate rows, which are grouped by the primary key of the target type. The primary key columns must exactly correspond to columns of this source table. If no primary key is defined, then the resulting table has one row, which is the aggregate result of all the rows of this table. The view returned by this method is unmodifiable, and closing it has no effect.
      Throws:
      NullPointerException - if any parameter is null
      IllegalArgumentException - if target primary key is malformed
      IOException
    • group

      default <T> Table<T> group(String groupBy, String orderBy, Class<T> targetType, Grouper.Factory<R,T> factory) throws IOException
      Returns a view backed by this table, which processes groups of source rows into groups of target rows. The view returned by this method is unmodifiable, closing it has no effect, and a ViewConstraintException is thrown from operations which act upon a primary key.
      Parameters:
      groupBy - grouping specification; pass an empty string to group all source rows together
      orderBy - ordering specification within each group; pass an empty string if undefined
      Throws:
      NullPointerException - if any parameter is null
      IllegalArgumentException - if groupBy or orderBy specification is malformed
      IllegalStateException - if any groupBy or orderBy columns don't exist
      IOException
    • join

      static <J> Table<J> join(Class<J> joinType, String spec, Table<?>... tables) throws IOException
      Joins tables together into an unmodifiable view. The returned view doesn't have any primary key, and so operations which act upon one aren't supported. In addition, closing the view doesn't have any effect.

      The joinType parameter is a class which resembles an ordinary row definition except that all columns must refer to other row types. Any annotations which define keys and indexes are ignored.

      The join specification consists of each join column, separated by a join operator, and possibly grouped with parenthesis:

      
       JoinOp = Source { Type Source }
       Source = Column | Group
       Group  = "(" JoinOp ")"
       Column = string
       Type   = ":" | ">:" | ":<" | ">:<" | ">" | "<" | "><"
      
       a : b    inner join
       a >: b   left outer join
       a :< b   right outer join
       a >:< b  full outer join
       a > b    left anti join
       a < b    right anti join
       a >< b   full anti join
       

      In order for a requested join type to work correctly, a suitable join filter must be provided by a query. Scanning all rows of the table without a join filter results in a cross join.

      Parameters:
      spec - join specification
      Throws:
      NullPointerException - if any parameters are null
      IllegalArgumentException - if join type is malformed, or if the specification is malformed, or if there are any table matching issues
      IOException
      See Also:
    • join

      static Table<Row> join(String spec, Table<?>... tables) throws IOException
      Joins tables together into a generated join type class.
      Parameters:
      spec - join specification
      Throws:
      NullPointerException - if any parameters are null
      IllegalArgumentException - if the specification is malformed, or if there are any table matching issues
      IOException
      See Also:
    • join

      static Table<Row> join()
      Returns an unmodifiable table consisting of one row with no columns, representing the identity element when joining an empty set of tables. Calling derive against the join identity table can be used to perform arbitrary expression evaluation.
    • derive

      <D> Table<D> derive(Class<D> derivedType, String query, Object... args) throws IOException
      Returns a view backed by this table, specified by a fully-featured query expression. The returned table instance will throw a ViewConstraintException for operations against rows which are restricted by the query, and closing the table has no effect.
      Parameters:
      derivedType - the projected query columns must correspond to columns defined in the derived row type
      Throws:
      IOException
    • derive

      Table<Row> derive(String query, Object... args) throws IOException
      Returns a view backed by this table, specified by a fully-featured query expression. The returned table instance will throw a ViewConstraintException for operations against rows which are restricted by the query, and closing the table has no effect.
      Throws:
      IOException
    • concat

      static <T> Table<T> concat(Class<T> targetType, Table<?>... sources) throws IOException
      Returns a view consisting of all rows from the given source tables concatenated together, possibly resulting in duplicate rows. All of the rows are mapped to the target type, applying any necessary column value conversions. The returned table instance will throw a ConversionException for operations against rows which cannot be converted back source rows, and closing the table has no effect.
      Parameters:
      targetType - target row type; the primary key is possibly ignored
      sources - source tables to concatenate; if none are provided, then the returned view is empty
      Throws:
      NullPointerException - if any parameter is null
      IOException
      See Also:
    • concat

      static Table<Row> concat(Table<?>... sources) throws IOException
      Returns a view consisting of all rows from the given source tables concatenated together, possibly resulting in duplicate rows. All of the rows are mapped to an automatically selected target type (possibly generated), applying any necessary column value conversions. The returned table instance will throw a ConversionException for operations against rows which cannot be converted back source rows, and closing the table has no effect.
      Parameters:
      sources - source tables to concatenate; if none are provided, then the returned view is empty
      Returns:
      a table whose row type primary key consists of all the source columns, but the table doesn't actually have a primary key
      Throws:
      NullPointerException - if any parameter is null
      IOException
      See Also:
    • distinct

      Table<R> distinct() throws IOException
      Returns a view of this table which has duplicate rows filtered out. If this table doesn't have any duplicates, then it's simply returned as-is. If an actual view is returned, then the instance is unmodifiable, and closing it has no effect.
      Throws:
      IOException
    • comparator

      default Comparator<R> comparator(String spec)
      Returns a row comparator based on the given specification, which defines the ordering columns. Each column name is prefixed with '+' or '-', to indicate ascending or descending order. For example: "+lastName+firstName-birthdate". By default, nulls are treated as higher than non-nulls, but a '!' after the '+'/'-' character causes nulls to be treated as lower than non-nulls.
      Throws:
      IllegalArgumentException - if the specification is malformed
      IllegalStateException - if the specification refers to non-existent columns
    • predicate

      default Predicate<R> predicate(String query, Object... args)
      Returns a row predicate for the given query expression and arguments.
    • close

      void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
      See Also:
    • isClosed

      boolean isClosed()