Class SQL


  • public final class SQL
    extends Object

    DSL for using Mango SQL

    • Field Detail

      • ALL

        public static final SQLElement ALL
        SQLElement representing "*" for selecting ALL
      • INDEXED_ARGUMENT

        public static final SQLElement INDEXED_ARGUMENT
        SQLElement representing "?" of use with PreparedStatements
    • Method Detail

      • C

        public static SQLOperable C​(String column)
        An SQLOperable defining a column name.
        Parameters:
        column - the column name
        Returns:
        the SQLOperable
      • column

        public static Column column​(String name,
                                    String type)
        Static method for constructing a new Column given its name and type.
        Parameters:
        name - the name of the column
        type - the data type of the column
        Returns:
        the column
      • C

        public static SQLOperable C​(String table,
                                    String column)
        An SQLOperable defining a fully qualified column name.
        Parameters:
        table - the table name
        column - the column name
        Returns:
        the SQLOperable
      • L

        public static SQLOperable L​(@NonNull
                                    @NonNull String value)
        An SQLOperable defining a literal expression, which will automatically be placed in single quotes.
        Parameters:
        value - the literal value
        Returns:
        the SQLOperable
      • N

        public static SQLOperable N​(@NonNull
                                    @NonNull Number value)
        Generates an SQLOperable for a numeric value
        Parameters:
        value - the numeric value
        Returns:
        the SQLOperable
      • and

        public static SQLOperable and​(@NonNull
                                      @NonNull SQLElement... elements)
        Combines one or more SQLElements via an AND
        Parameters:
        elements - the elements to AND
        Returns:
        the SQLOperable
      • exists

        public static SQLOperable exists​(@NonNull
                                         @NonNull QueryStatement query)
        Creates an "exists" cause checking for the existence of a record in a sub query.
        Parameters:
        query - the sub query
        Returns:
        the SQLOperable
      • group

        public static SQLOperable group​(@NonNull
                                        @NonNull SQLElement... elements)
        Groups one or more expressions by placing them in parenthesis
        Parameters:
        elements - the elements to group
        Returns:
        the SQLOperable
      • namedArgument

        public static SQLOperable namedArgument​(@NonNull
                                                @NonNull String name)
        Generates a named argument for use with NamedPreparedStatement
        Parameters:
        name - the name of the argument
        Returns:
        the SQLOperable
      • namedArgument

        public static SQLElement namedArgument​(@NonNull
                                               @NonNull SQLElement name)
        Named argument sql element.
        Parameters:
        name - the name
        Returns:
        the sql element
      • nullValue

        public static SQLElement nullValue()
        Generates a null value
        Returns:
        the SQLElement
      • or

        public static SQLOperable or​(@NonNull
                                     @NonNull SQLElement... elements)
        Combines one or more SQLElements via an OR
        Parameters:
        elements - the elements to OR
        Returns:
        the SQLOperable
      • query

        public static QueryStatement query​(String statement)
        Free form SQL query statement
        Parameters:
        statement - the statement
        Returns:
        the SQLQueryStatement
      • sql

        public static SQLElement sql​(@NonNull
                                     @NonNull String... components)
        Free form SQL from one or more sql statements
        Parameters:
        components - the components
        Returns:
        the sql element
      • update

        public static UpdateStatement update​(String statement)
        Free form SQL update statement
        Parameters:
        statement - the statement
        Returns:
        the SQLUpdateStatement
      • columnNamesEqual

        public static boolean columnNamesEqual​(String c1,
                                               String c2)