Class FunctionExpression

All Implemented Interfaces:
ColumnExpression, DelegateExpression, SelectExpression
Direct Known Subclasses:
Abs, Avg, Lower, Max, Min, Substring, Upper

public abstract class FunctionExpression extends AliasedDelegateColumnExpression
Base class for function expressions operating on a column.
  • Constructor Details

    • FunctionExpression

      public FunctionExpression(ColumnExpression target, ColumnIdentifierGenerator columnIdentifierGenerator)
      Constructor.
      Parameters:
      target - Target column expression to encapsulate.
      columnIdentifierGenerator - Database provider-specific column identifier generator.
  • Method Details

    • toSql

      public String toSql(Operation operation)
      Creates a SQL representation of the expression.

      This is usually used for expressions that do not require any aliases.

      Specified by:
      toSql in interface SelectExpression
      Overrides:
      toSql in class AliasedDelegateColumnExpression
      Parameters:
      operation - the operation that is being executed
      Returns:
      the SQL representation of the expression
    • toSqlWithAlias

      public String toSqlWithAlias(Operation operation)
      Creates a SQL representation of the expression, specifically including any required aliases.
      Overrides:
      toSqlWithAlias in class AliasedDelegateColumnExpression
      Parameters:
      operation - the operation that is being executed
      Returns:
      the SQL representation of the expression
    • prepareSql

      protected String prepareSql(Operation operation, boolean alias)
      Prepare SQL representation of the function.
      Parameters:
      operation - The operation that is being executed
      alias - Whether to alias the SQL function result
      Returns:
      SQL representation of the function
    • template

      protected abstract String template()
      Gets the template for the SQL representation of the function.

      The template should contain a single "%s" placeholder for the column identifier.

      Returns:
      SQL representation template