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

    • name

      protected final String name
    • table

      protected final SqlTable table
    • jdbcType

      protected final JDBCType jdbcType
    • isDescending

      protected final boolean isDescending
    • alias

      protected final String alias
    • typeHandler

      protected final String typeHandler
    • renderingStrategy

      protected final RenderingStrategy renderingStrategy
    • parameterTypeConverter

      protected final ParameterTypeConverter<T,?> parameterTypeConverter
    • tableQualifier

      protected final String tableQualifier
    • javaType

      protected final Class<T> javaType
  • 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. This 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
    • render

      public FragmentAndParameters render(RenderingContext renderingContext)
      Description copied from interface: BasicColumn
      Returns a rendering of the column. The rendered fragment should include the table alias based on the TableAliasCalculator in the RenderingContext. The fragment could contain prepared statement parameter markers and associated parameter values if desired.
      Specified by:
      render in interface BasicColumn
      Parameters:
      renderingContext - the rendering context (strategy, sequence, etc.)
      Returns:
      a rendered SQL fragment and, optionally, parameters associated with the fragment
    • 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)