java.lang.Object
org.springframework.data.relational.core.sql.InlineQuery
All Implemented Interfaces:
Segment, TableLike, Visitable

public class InlineQuery extends Object implements TableLike
Represents a inline query within a SQL statement. Typically, used in FROM or JOIN clauses.

Renders to: (>SELECT<) AS >ALIAS< in a from or join clause, and to >ALIAS< when used in an expression.

Note that this does not implement Aliased because the Alias is not optional but required and therefore more like a name although the SQL term is "alias".

Since:
2.3
Author:
Jens Schauder
  • Method Details

    • create

      public static InlineQuery create(Select select, SqlIdentifier alias)
      Creates a new InlineQuery using an alias.
      Parameters:
      select - must not be null.
      alias - must not be null or empty.
      Returns:
      the new InlineQuery using the alias.
    • create

      public static InlineQuery create(Select select, String alias)
      Creates a new InlineQuery using an alias.
      Parameters:
      select - must not be null or empty.
      alias - must not be null or empty.
      Returns:
      the new InlineQuery using the alias.
    • getName

      public SqlIdentifier getName()
      Specified by:
      getName in interface TableLike
      Returns:
      the table name.
    • getReferenceName

      public SqlIdentifier getReferenceName()
      Specified by:
      getReferenceName in interface TableLike
      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 assume that the Segment.toString() representation works across multiple databases.

      Specified by:
      toString in interface Segment
      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 Visitables 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 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
      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.