java.lang.Object
org.springframework.data.relational.core.sql.Column
All Implemented Interfaces:
Expression, Named, Segment, Visitable

public class Column extends Object implements Expression, Named
Column name within a SELECT … FROM clause.

Renders to: <name> or <table(alias)>.<name>.

Since:
1.1
Author:
Mark Paluch, Jens Schauder
  • Method Details

    • create

      public static Column create(String name, TableLike table)
      Creates a new Column associated with a Table.
      Parameters:
      name - column name, must not null or empty.
      table - the table, must not be null.
      Returns:
      the new Column.
      Since:
      2.3
    • create

      public static Column create(SqlIdentifier name, Table table)
      Creates a new Column associated with a Table.
      Parameters:
      name - column name, must not null.
      table - the table, must not be null.
      Returns:
      the new Column.
      Since:
      2.0
    • aliased

      public static Column aliased(String name, Table table, String alias)
      Creates a new aliased Column associated with a Table.
      Parameters:
      name - column name, must not null or empty.
      table - the table, must not be null.
      alias - column alias name, must not null or empty.
      Returns:
      the new Column.
    • as

      public Column as(String alias)
      Creates a new aliased Column.
      Parameters:
      alias - column alias name, must not null or empty.
      Returns:
      the aliased Column.
    • as

      public Column as(SqlIdentifier alias)
      Creates a new aliased Column.
      Parameters:
      alias - column alias name, must not null.
      Returns:
      the aliased Column.
      Since:
      2.0
    • from

      public Column from(Table table)
      Creates a new Column associated with a Table.
      Parameters:
      table - the table, must not be null.
      Returns:
      a new Column associated with Table.
    • isEqualTo

      public Comparison isEqualTo(Expression expression)
      Creates a = (equals) Condition.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the Comparison condition.
    • isNotEqualTo

      public Comparison isNotEqualTo(Expression expression)
      Creates a != (not equals) Condition.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the Comparison condition.
    • between

      public Between between(Expression begin, Expression end)
      Creates a BETWEEN Condition.
      Parameters:
      begin - begin value for the comparison.
      end - end value for the comparison.
      Returns:
      the Between condition.
      Since:
      2.0
    • notBetween

      public Between notBetween(Expression begin, Expression end)
      Creates a NOT BETWEEN Condition.
      Parameters:
      begin - begin value for the comparison.
      end - end value for the comparison.
      Returns:
      the Between condition.
      Since:
      2.0
    • isLess

      public Comparison isLess(Expression expression)
      Creates a < (less) Condition.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the Comparison condition.
    • isLessOrEqualTo

      public Comparison isLessOrEqualTo(Expression expression)
      CCreates a <= (greater) Condition.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the Comparison condition.
    • isGreater

      public Comparison isGreater(Expression expression)
      Creates a != (not equals) Condition.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the Comparison condition.
    • isGreaterOrEqualTo

      public Comparison isGreaterOrEqualTo(Expression expression)
      Creates a <= (greater or equal to) Condition.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the Comparison condition.
    • like

      public Like like(Expression expression)
      Creates a LIKE Condition.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the Like condition.
    • notLike

      public Like notLike(Expression expression)
      Creates a NOT LIKE Condition.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the Like condition.
      Since:
      2.0
    • in

      public In in(Expression... expression)
      Creates a new In Condition given right Expressions.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the In condition.
    • in

      public In in(Select subselect)
      Creates a new In Condition given a subselects.
      Parameters:
      subselect - right side of the comparison.
      Returns:
      the In condition.
    • notIn

      public In notIn(Expression... expression)
      Creates a new not In Condition given right Expressions.
      Parameters:
      expression - right side of the comparison.
      Returns:
      the In condition.
    • notIn

      public In notIn(Select subselect)
      Creates a new not In Condition given a subselects.
      Parameters:
      subselect - right side of the comparison.
      Returns:
      the In condition.
    • isNull

      public IsNull isNull()
      Creates a IS NULL condition.
      Returns:
      the IsNull condition.
    • isNotNull

      public Condition isNotNull()
      Creates a IS NOT NULL condition.
      Returns:
      the Condition condition.
    • set

      public AssignValue set(Expression value)
      Creates a value assignment.
      Parameters:
      value - the value to assign.
      Returns:
      the AssignValue assignment.
    • getName

      public SqlIdentifier getName()
      Specified by:
      getName in interface Named
      Returns:
      the name of the underlying element.
    • getReferenceName

      public SqlIdentifier getReferenceName()
      Returns:
      the column name as it is used in references. This can be the actual name or an alias.
    • getTable

      @Nullable public TableLike getTable()
      Returns:
      the Table. Can be null if the column was not referenced in the context of a Table.
    • 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 assume that the Segment.toString() representation works across multiple databases.

      Specified by:
      toString in interface Segment
      Returns:
      a SQL string representation of this Segment.
    • equals

      public boolean equals(@Nullable Object o)
      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
      Parameters:
      o - the reference object with which to compare.
      Returns:
      true if this object is the same as the other argument; false otherwise.
    • hashCode

      public int hashCode()
      Description copied from interface: Segment
      Generate a hash code from thisSegment.

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

      Specified by:
      hashCode in interface Segment
      Returns:
      a hash code value for this object.
    • visit

      public void visit(Visitor visitor)
      Description copied from interface: Visitable
      Accept a Visitor visiting this Visitable and its nested Visitables if applicable.
      Specified by:
      visit in interface Visitable
      Parameters:
      visitor - the visitor to notify, must not be null.