Class SqlColumn<T>

java.lang.Object
org.mybatis.dynamic.sql.SqlColumn<T>
All Implemented Interfaces:
BasicColumn, BindableColumn<T>, SortSpecification

public class SqlColumn<T> extends Object implements BindableColumn<T>, SortSpecification
  • Field Details

  • Method Details

    • name

      public String name()
    • table

      public SqlTable table()
    • jdbcType

      public Optional<JDBCType> jdbcType()
      Specified by:
      jdbcType in interface BindableColumn<T>
    • alias

      public Optional<String> alias()
      Description copied from interface: BasicColumn
      Returns the columns alias if one has been specified.
      Specified by:
      alias in interface BasicColumn
      Returns:
      the column alias
    • typeHandler

      public Optional<String> typeHandler()
      Specified by:
      typeHandler in interface BindableColumn<T>
    • javaType

      public Optional<Class<T>> javaType()
      Specified by:
      javaType in interface BindableColumn<T>
    • convertParameterType

      public Object convertParameterType(T value)
      Specified by:
      convertParameterType in interface BindableColumn<T>
    • descending

      public SortSpecification descending()
      Description copied from interface: SortSpecification
      Returns a new instance of the SortSpecification that should render as descending in an ORDER BY clause.
      Specified by:
      descending in interface SortSpecification
      Returns:
      new instance of SortSpecification
    • as

      public SqlColumn<T> as(String alias)
      Description copied from interface: BindableColumn
      Override the base method definition to make it more specific to this interface.
      Specified by:
      as in interface BasicColumn
      Specified by:
      as in interface BindableColumn<T>
      Parameters:
      alias - the column alias to set
      Returns:
      new instance with alias set
    • qualifiedWith

      public SqlColumn<T> qualifiedWith(String tableQualifier)
      Override the calculated table qualifier if there is one. This is useful for sub-queries where the calculated table qualifier may not be correct in all cases.
      Parameters:
      tableQualifier - the table qualifier to apply to the rendered column name
      Returns:
      a new column that will be rendered with the specified table qualifier
    • asCamelCase

      public SqlColumn<T> asCamelCase()
      Set an alias with a camel cased string based on the column name. The can be useful for queries using the CommonSelectMapper where the columns are placed into a map based on the column name returned from the database.

      A camel case string is mixed case, and most databases do not support unquoted mixed case strings as identifiers. Therefore the generated alias will be surrounded by double quotes thereby making it a quoted identifier. Most databases will respect quoted mixed case identifiers.

      Returns:
      a new column aliased with a camel case version of the column name
    • isDescending

      public boolean isDescending()
      Description copied from interface: SortSpecification
      Return true if the sort order is descending.
      Specified by:
      isDescending in interface SortSpecification
      Returns:
      true if the SortSpecification should render as descending
    • orderByName

      public String orderByName()
      Description copied from interface: SortSpecification
      Return the phrase that should be written into a rendered order by clause. This should NOT include the "DESC" word for descending sort specifications.
      Specified by:
      orderByName in interface SortSpecification
      Returns:
      the order by phrase
    • renderWithTableAlias

      public String renderWithTableAlias(TableAliasCalculator tableAliasCalculator)
      Description copied from interface: BasicColumn
      Returns the name of the item aliased with a table name if appropriate. For example, "a.foo". This is appropriate for where clauses and order by clauses.
      Specified by:
      renderWithTableAlias in interface BasicColumn
      Parameters:
      tableAliasCalculator - the table alias calculator for the current renderer
      Returns:
      the item name with the table alias applied
    • renderingStrategy

      public Optional<RenderingStrategy> renderingStrategy()
      Specified by:
      renderingStrategy in interface BindableColumn<T>
    • withTypeHandler

      @NotNull public <S> SqlColumn<S> withTypeHandler(String typeHandler)
    • withRenderingStrategy

      @NotNull public <S> SqlColumn<S> withRenderingStrategy(RenderingStrategy renderingStrategy)
    • withParameterTypeConverter

      @NotNull public <S> SqlColumn<S> withParameterTypeConverter(ParameterTypeConverter<S,?> parameterTypeConverter)
    • withJavaType

      @NotNull public <S> SqlColumn<S> withJavaType(Class<S> javaType)
    • of

      public static <T> SqlColumn<T> of(String name, SqlTable table)
    • of

      public static <T> SqlColumn<T> of(String name, SqlTable table, JDBCType jdbcType)