org.springframework.data.relational.core.sql

## Class Table

- java.lang.Object
- - org.springframework.data.relational.core.sql.Table

All Implemented Interfaces:
  Segment, Visitable

    public class Table
    extends Object

Represents a table reference within an SQL statement. Typically used to denote `FROM` or `JOIN` or to prefix a `Column`.

Renders to: `<name>` or `<name> AS <name>`.

Since:
  1.1
Author:
  Mark Paluch

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static Table` `aliased(String name, String alias)` Creates a new `Table` using an `alias`.
`Table` `as(SqlIdentifier alias)` Creates a new `Table` aliased to `alias`.
`Table` `as(String alias)` Creates a new `Table` aliased to `alias`.
`AsteriskFromTable` `asterisk()` Creates a `AsteriskFromTable` maker selecting all columns from this `Table` (e.g.
`Column` `column(SqlIdentifier name)` Creates a new `Column` associated with this `Table`.
`Column` `column(String name)` Creates a new `Column` associated with this `Table`.
`List<Column>` `columns(Collection<String> names)` Creates a `List` of `Column`s associated with this `Table`.
`List<Column>` `columns(SqlIdentifier... names)` Creates a `List` of `Column`s associated with this `Table`.
`List<Column>` `columns(String... names)` Creates a `List` of `Column`s associated with this `Table`.
`static Table` `create(SqlIdentifier name)` Creates a new `Table` given `name`.
`static Table` `create(String name)` Creates a new `Table` given `name`.
`boolean` `equals(Object obj)` Check whether this `Segment` is equal to another `Segment`.
`SqlIdentifier` `getName()`
`SqlIdentifier` `getReferenceName()`
`int` `hashCode()` Generate a hash code from this`Segment`.
`String` `toString()` Return a SQL string representation of this `Segment`.
`void` `visit(Visitor visitor)` Accept a `Visitor` visiting this `Visitable` and its nested `Visitable`s if applicable.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Method Detail

#### create

    public static Table create(String name)

Creates a new `Table` given `name`.

Parameters:
  `name` - must not be null or empty.
Returns:
  the new `Table`.

#### create

    public static Table create(SqlIdentifier name)

Creates a new `Table` given `name`.

Parameters:
  `name` - must not be null or empty.
Returns:
  the new `Table`.
Since:
  2.0

#### aliased

    public static Table aliased(String name,
                                String alias)

Creates a new `Table` using an `alias`.

Parameters:
  `name` - must not be null or empty.
  `alias` - must not be null or empty.
Returns:
  the new `Table` using the `alias`.

#### as

    public Table as(String alias)

Creates a new `Table` aliased to `alias`.

Parameters:
  `alias` - must not be null or empty.
Returns:
  the new `Table` using the `alias`.

#### as

    public Table as(SqlIdentifier alias)

Creates a new `Table` aliased to `alias`.

Parameters:
  `alias` - must not be null or empty.
Returns:
  the new `Table` using the `alias`.
Since:
  2.0

#### column

    public Column column(String name)

Creates a new `Column` associated with this `Table`.

Note: This `Table` does not track column creation and there is no possibility to enumerate all `Column`s that were created for this table.

Parameters:
  `name` - column name, must not be null or empty.
Returns:
  a new `Column` associated with this `Table`.

#### column

    public Column column(SqlIdentifier name)

Creates a new `Column` associated with this `Table`.

Note: This `Table` does not track column creation and there is no possibility to enumerate all `Column`s that were created for this table.

Parameters:
  `name` - column name, must not be null or empty.
Returns:
  a new `Column` associated with this `Table`.
Since:
  2.0

#### columns

    public List<Column> columns(String... names)

Creates a `List` of `Column`s associated with this `Table`.

Note: This `Table` does not track column creation and there is no possibility to enumerate all `Column`s that were created for this table.

Parameters:
  `names` - column names, must not be null or empty.
Returns:
  a new `List` of `Column`s associated with this `Table`.

#### columns

    public List<Column> columns(SqlIdentifier... names)

Creates a `List` of `Column`s associated with this `Table`.

Note: This `Table` does not track column creation and there is no possibility to enumerate all `Column`s that were created for this table.

Parameters:
  `names` - column names, must not be null or empty.
Returns:
  a new `List` of `Column`s associated with this `Table`.
Since:
  2.0

#### columns

    public List<Column> columns(Collection<String> names)

Creates a `List` of `Column`s associated with this `Table`.

Note: This `Table` does not track column creation and there is no possibility to enumerate all `Column`s that were created for this table.

Parameters:
  `names` - column names, must not be null or empty.
Returns:
  a new `List` of `Column`s associated with this `Table`.

#### asterisk

    public AsteriskFromTable asterisk()

Creates a `AsteriskFromTable` maker selecting all columns from this `Table` (e.g. `SELECT <table> .*`.

Returns:
  the select all marker for this `Table`.

#### getName

    public SqlIdentifier getName()

Returns:
  the table name.

#### getReferenceName

    public SqlIdentifier getReferenceName()

Returns:
  the table name as it is used in references. This can be the actual `name` or an `alias`.

#### toString

    public String toString()

Description copied from interface: `Segment`
Return a SQL string representation of this `Segment`.

The representation is intended for debugging purposes and an approximation to the generated SQL. While it might work in the context of a specific dialect, you should not that the `Segment.toString()` representation works across multiple databases.

Specified by:
  `toString` in interface `Segment`
Overrides:
  `toString` in class `Object`
Returns:
  a SQL string representation of this `Segment`.

#### visit

    public void visit(Visitor visitor)

Description copied from interface: `Visitable`
Accept a `Visitor` visiting this `Visitable` and its nested `Visitable`s if applicable.

Specified by:
  `visit` in interface `Visitable`
Parameters:
  `visitor` - the visitor to notify, must not be null.

#### hashCode

    public int hashCode()

Description copied from interface: `Segment`
Generate a hash code from this`Segment`.

Hashcode typically derives from the `Segment.toString()` representation so two `Segment`s yield the same `Segment.hashCode()` if their `Segment.toString()` representation matches.

Specified by:
  `hashCode` in interface `Segment`
Overrides:
  `hashCode` in class `Object`
Returns:
  a hash code value for this object.

#### equals

    public boolean equals(Object obj)

Description copied from interface: `Segment`
Check whether this `Segment` is equal to another `Segment`.

Equality is typically given if the `Segment.toString()` representation matches.

Specified by:
  `equals` in interface `Segment`
Overrides:
  `equals` in class `Object`
Parameters:
  `obj` - the reference object with which to compare.
Returns:
  true if this object is the same as the `other` argument; false otherwise.