class CachedRunningQuery extends AbstractRunningQuery {

    public boolean update(String fields, String conditions, String grouping, String order, Integer pagesize) throws SQLException {
        try {
            boolean mustInitialize = false;
            boolean fieldChanged = false;
            
            if (!StringUtils.equals(this.fields, fields) || this.fields != null) {
                this.fields = fields;
                fieldChanged = true;
            }
            if (!StringUtils.equals(this.conditions, conditions) || this.conditions != null) {
                this.conditions = conditions;
                fieldChanged = true;
            }
            if (!StringUtils.equals(this.grouping, grouping) || this.grouping != null) {
                this.grouping = grouping;
                fieldChanged = true;
            }
            if (!StringUtils.equals(this.order, order) || this.order != null) {
                this.order = order;
                fieldChanged = true;
            }
            
            String newSql = null;
            if (this.view != null) {
                
                if (fieldChanged == true) {
                    newSql = generateSql(this.view, this.fields, this.conditions, this.grouping, this.order, this.user, this.connection);
                    // only if changed
                    if (!newSql.equals(this.sqlQuery)) {
                        mustInitialize = true;
                    }
                    
                    if (pagesize != null) {
                        if (!pagesize.equals(this.pagesize)) {
                            this.pagesize = pagesize;
                            mustInitialize = true;
                        }
                    }
                }
            }
            
            return mustInitialize;
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            throw e;
        }
    }

    private  CachedRunningQuery(QueryMetricFactory metricFactory);
    public  CachedRunningQuery(Query query, QueryLogic<?> queryLogic, String queryId, String alias, String user, String view, int pagesize,
                    String originalQueryId, Set<String> variableFields, Set<String> fixedFieldsInEvent, QueryMetricFactory metricFactory);
    public  CachedRunningQuery(Connection connection, Query query, QueryLogic<?> queryLogic, String queryId, String alias, String user, String view,
                    String fields, String conditions, String grouping, String order, int pagesize, Set<String> variableFields, Set<String> fixedFieldsInEvent,
                    QueryMetricFactory metricFactory);

}