Class SelectBuilder


  • public class SelectBuilder
    extends java.lang.Object
    SQL SELECT query builder.
    This class should be instanciated through SQL static method.
    Since:
    0.1
    • Constructor Detail

      • SelectBuilder

        public SelectBuilder()
        SelectBuilder constructor
    • Method Detail

      • distinct

        public SelectBuilder distinct()
        Add DISTINCT command
        Returns:
        this
      • toString

        public java.lang.String toString()
        Get SQL query.
        Overrides:
        toString in class java.lang.Object
      • field

        public FieldsBuilder field​(java.lang.String column)
        Return a new field builder
        Parameters:
        column - the selected column
        Returns:
        the new FieldsBuilder
      • groupBy

        public FieldsBuilder groupBy​(java.lang.String column)
        Add SQL GROUP BY command
        Parameters:
        column - the first column to group by
        Returns:
        a new FieldsBuilder to add other columns
      • orderBy

        public FieldsBuilder orderBy​(java.lang.String column)
        Add SQL ORDER BY command.
        Parameters:
        column - the first column to order by
        Returns:
        a new FieldsBuilder to add other columns
      • having

        public SelectBuilder having​(ClausesBuilder clauses)
        Add SQL HAVING command and its clauses if not empty
        Parameters:
        clauses - the clauses
        Returns:
        this
      • union

        public SelectBuilder union​(SelectBuilder other)
        Add UNION to other SQL request
        Parameters:
        other - the other SQL request
        Returns:
        this
      • unionAll

        public SelectBuilder unionAll​(SelectBuilder other)
        Add UNION ALL to other SQL request with duplicate entries
        Parameters:
        other - the other SQL request
        Returns:
        this
      • offset

        public SelectBuilder offset​(long offset)
        Add OFFSET n ROWS
        Parameters:
        offset - the offset value
        Returns:
        this
      • fetch

        public SelectBuilder fetch​(long limit)
        Add FETCH FIRST n ROWS ONLY
        Parameters:
        limit - the limit value
        Returns:
        this
      • build

        public SQLQuery build()
        Build SQL query
        Returns:
        the query and its prepared statement values