Package com.vaadin.addon.sqlcontainer.query.generator

Examples of com.vaadin.addon.sqlcontainer.query.generator.StatementHelper


  @Override
  public StatementHelper getQueryStatement(int offset, int limit)
      throws UnsupportedOperationException {

    StatementHelper sh = new StatementHelper();
    StringBuffer query = new StringBuffer(
        "SELECT id, service, theme, observations, action FROM myActions");
    if (filters != null) {
      for (Filter f : filters) {
        generateFilter(query, f, filters.indexOf(f) == 0,
            FilteringMode.FILTERING_MODE_INCLUSIVE, sh);
      }
    }
    query.append(getOrderByString());
    if (offset != 0 || limit != 0) {
      query.append(" LIMIT ").append(limit);
      query.append(" OFFSET ").append(offset);
    }
    sh.setQueryString(query.toString());
    return sh;
  }
View Full Code Here


  @Override
  public StatementHelper getCountStatement()
      throws UnsupportedOperationException {

    StatementHelper sh = new StatementHelper();
    StringBuffer query = new StringBuffer("SELECT COUNT(*) FROM myActions");
    if (filters != null) {
      for (Filter f : filters) {
        generateFilter(query, f, filters.indexOf(f) == 0,
            FilteringMode.FILTERING_MODE_INCLUSIVE, sh);
      }
    }
    sh.setQueryString(query.toString());
    return sh;
  }
View Full Code Here

  @Override
  public StatementHelper getContainsRowQueryStatement(Object... keys)
      throws UnsupportedOperationException {

    StatementHelper sh = new StatementHelper();
    StringBuffer query = new StringBuffer(
        "SELECT service, theme, observations, action FROM myActions WHERE idAeroport = ?");
    sh.addParameterValue(keys[0]);
    sh.setQueryString(query.toString());
    return sh;
  }
View Full Code Here

            return count;
        }
        /* First try using prepared statement */
        if (delegate instanceof FreeformStatementDelegate) {
            try {
                StatementHelper sh = ((FreeformStatementDelegate) delegate)
                        .getCountStatement();
                Connection c = getConnection();
                PreparedStatement pstmt = c.prepareStatement(sh
                        .getQueryString());
                sh.setParameterValuesToStatement(pstmt);
                ResultSet rs = pstmt.executeQuery();
                rs.next();
                count = rs.getInt(1);
                rs.close();
                pstmt.clearParameters();
View Full Code Here

        String query = queryString;
        if (delegate != null) {
            /* First try using prepared statement */
            if (delegate instanceof FreeformStatementDelegate) {
                try {
                    StatementHelper sh = ((FreeformStatementDelegate) delegate)
                            .getQueryStatement(offset, pagelength);
                    PreparedStatement pstmt = activeConnection
                            .prepareStatement(sh.getQueryString());
                    sh.setParameterValuesToStatement(pstmt);
                    return pstmt.executeQuery();
                } catch (UnsupportedOperationException e) {
                    // Statement generation not supported, continue...
                }
            }
View Full Code Here

            return false;
        }
        /* First try using prepared statement */
        if (delegate instanceof FreeformStatementDelegate) {
            try {
                StatementHelper sh = ((FreeformStatementDelegate) delegate)
                        .getCountStatement();
                if (sh != null && sh.getQueryString() != null
                        && sh.getQueryString().length() > 0) {
                    return true;
                }
            } catch (UnsupportedOperationException e) {
                // Statement generation not supported, continue...
            }
View Full Code Here

        String query = null;
        boolean contains = false;
        if (delegate != null) {
            if (delegate instanceof FreeformStatementDelegate) {
                try {
                    StatementHelper sh = ((FreeformStatementDelegate) delegate)
                            .getContainsRowQueryStatement(keys);
                    Connection c = getConnection();
                    PreparedStatement pstmt = c.prepareStatement(sh
                            .getQueryString());
                    sh.setParameterValuesToStatement(pstmt);
                    ResultSet rs = pstmt.executeQuery();
                    contains = rs.next();
                    rs.close();
                    pstmt.clearParameters();
                    pstmt.close();
View Full Code Here

     *
     * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#getCount()
     */
    public int getCount() throws SQLException {
        debug("Fetching count...");
        StatementHelper sh = sqlGenerator.generateSelectQuery(tableName,
                filters, filterMode, null, 0, 0, "COUNT(*)");
        boolean shouldCloseTransaction = false;
        if (!transactionOpen) {
            shouldCloseTransaction = true;
            beginTransaction();
View Full Code Here

     *
     * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#getResults(int,
     * int)
     */
    public ResultSet getResults(int offset, int pagelength) throws SQLException {
        StatementHelper sh;
        /*
         * If no ordering is explicitly set, results will be ordered by the
         * first primary key column.
         */
        if (orderBys == null || orderBys.isEmpty()) {
View Full Code Here

    public int storeRow(RowItem row) throws UnsupportedOperationException,
            SQLException {
        if (row == null) {
            throw new IllegalArgumentException("Row argument must be non-null.");
        }
        StatementHelper sh;
        int result = 0;
        if (row.getId() instanceof TemporaryRowId) {
            setVersionColumnFlagInProperty(row);
            sh = sqlGenerator.generateInsertQuery(tableName, row);
            result = executeUpdateReturnKeys(sh, row);
View Full Code Here

TOP

Related Classes of com.vaadin.addon.sqlcontainer.query.generator.StatementHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.