Class SelectHelper

    • Constructor Detail

      • SelectHelper

        public SelectHelper​(String table,
                            FieldList fl)
        Constructor for a SelectHelper
        Parameters:
        table - the table to be wrapped
        fl - the field list
    • Method Detail

      • newCustomSelectHelper

        public static SelectHelper newCustomSelectHelper​(String table,
                                                         FieldList fl,
                                                         boolean firstParam,
                                                         String queryView)
        Creates a new SelectHelper NOTE : initSelectEntity() should not be invoked.
        Parameters:
        table - the entity this select helper is meant for.
        fl - the list of fields
        firstParam - true if WHERE must be set, false othewise.
        queryView - the query to use instead of default query build on TABLE name.
        Returns:
        a new SelectHelper
      • initSelectEntity

        public void initSelectEntity()
        Initialize this helper.
      • addWhereOrMode

        public boolean addWhereOrMode​(String mode)
        If no field has been set, WHERE will be added, otherwise 'mode' will be added.
        Parameters:
        mode - the mode to be added ( AND, OR )
        Returns:
        true if WHERE has been added, false otherwise.
        Since:
        8.0.1
      • addParam

        public boolean addParam​(String columnName,
                                Object value,
                                String mode,
                                String compare,
                                String parameter)
        Add a parameter to the query. The parameter is added if and only if the value is not null. If you want to add a null comparison use addNullComparison() method()
        Parameters:
        columnName - the name of the column
        value - the value
        mode - the mode (AND, OR)
        compare - the comparison type ( = , <>, >, <, <=, >=, LIKE )
        parameter - the parameter (for example section '?' or 'UPPER(?)')
        Returns:
        true if the parameter has been added, false otherwise.
        Since:
        8.0.1
      • addNullComparison

        public boolean addNullComparison​(String columnName,
                                         String mode,
                                         boolean isNull)
        Add a NULL check to the query.
        Parameters:
        columnName - the name of the column
        isNull - true to add 'IS NULL' check, false to add 'IS NOT NULL' check.
        mode - the mode (AND, OR)
        Returns:
        true if the parameter has been added, false otherwise.
        Since:
        8.0.1
      • addParam

        public boolean addParam​(String columnName,
                                Object value,
                                String mode,
                                String compare)
        Add a parameter to the query. The parameter is added if and only if the value is not null. If you want to add a null comparison use addNullComparison() method() The parameter will be added as a parameter (?) for prepared statement
        Parameters:
        columnName - the name of the column
        value - the value
        mode - the mode (AND, OR)
        compare - the comparison type ( = , <>, >, <, <=, >=, LIKE )
        Returns:
        true if the parameter has been added, false otherwise.
      • orEqualParam

        public boolean orEqualParam​(String columnName,
                                    Object value)
        Add a parameter to the query. The parameter is added if and only if the value is not null. If you want to add a null comparison use addNullComparison() method(). The parameter will be added as a parameter (?) for prepared statement. The mode will be OR and the comparison =
        Parameters:
        columnName - the name of the column
        value - the value
        Returns:
        true if the parameter has been added, false otherwise.
      • orLikeParam

        public boolean orLikeParam​(String columnName,
                                   Object value)
        Add a parameter to the query. The parameter is added if and only if the value is not null. If you want to add a null comparison use addNullComparison() method(). The parameter will be added as a parameter (?) for prepared statement. The mode will be OR and the comparison LIKE
        Parameters:
        columnName - the name of the column
        value - the value
        Returns:
        true if the parameter has been added, false otherwise.
      • andEqualParam

        public boolean andEqualParam​(String columnName,
                                     Object value)
        Add a parameter to the query. The parameter is added if and only if the value is not null. If you want to add a null comparison use addNullComparison() method(). The parameter will be added as a parameter (?) for prepared statement. The mode will be AND and the comparison =
        Parameters:
        columnName - the name of the column
        value - the value
        Returns:
        true if the parameter has been added, false otherwise.
      • andLikeParam

        public boolean andLikeParam​(String columnName,
                                    Object value)
        Add a parameter to the query. The parameter is added if and only if the value is not null. If you want to add a null comparison use addNullComparison() method(). The parameter will be added as a parameter (?) for prepared statement. The mode will be AND and the comparison LIKE
        Parameters:
        columnName - the name of the column
        value - the value
        Returns:
        true if the parameter has been added, false otherwise.
      • addOrderBy

        public void addOrderBy​(String columnName,
                               String orderByMode)
        Add ORDER BY to the query.
        Parameters:
        columnName - the column name
        orderByMode - the order mode (ASC, DESC)
      • addOrderBy

        public void addOrderBy​(String orderBy)
        Directly add ORDER BY to the query.
        Parameters:
        orderBy - string "ORDER BY ${orderBy}" will be added to the query buffer.
      • getQueryContent

        public String getQueryContent()
        Description copied from class: QueryHelper
        Builds the query context of all query buffer. (To be preferred to getQuery().toString() method).
        Overrides:
        getQueryContent in class QueryHelper
        Returns:
        the current query content