Package com.vaadin.data.util.sqlcontainer.query.generator

Examples of com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper


    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


    public RowId storeRowImmediately(RowItem row) throws SQLException {
        beginTransaction();
        /* Set version column, if one is provided */
        setVersionColumnFlagInProperty(row);
        /* Generate query */
        StatementHelper sh = sqlGenerator.generateInsertQuery(tableName, row);
        PreparedStatement pstmt = activeConnection.prepareStatement(
                sh.getQueryString(), primaryKeyColumns.toArray(new String[0]));
        sh.setParameterValuesToStatement(pstmt);
        logger.log(Level.FINE, "DB -> " + sh.getQueryString());
        int result = pstmt.executeUpdate();
        if (result > 0) {
            /*
             * If affected rows exist, we'll get the new RowId, commit the
             * transaction and return the new RowId.
View Full Code Here

        int ix = 0;
        for (String colName : primaryKeyColumns) {
            filtersAndKeys.add(new Equal(colName, keys[ix]));
            ix++;
        }
        StatementHelper sh = sqlGenerator.generateSelectQuery(tableName,
                filtersAndKeys, orderBys, 0, 0, "*");

        boolean shouldCloseTransaction = false;
        if (!transactionOpen) {
            shouldCloseTransaction = true;
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()
     */
    @Override
    public int getCount() throws SQLException {
        getLogger().log(Level.FINE, "Fetching count...");
        StatementHelper sh = sqlGenerator.generateSelectQuery(
                getFullTableName(), filters, null, 0, 0, "COUNT(*)");
        boolean shouldCloseTransaction = false;
        if (!isInTransaction()) {
            shouldCloseTransaction = true;
            beginTransaction();
View Full Code Here

     * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#getResults(int,
     * int)
     */
    @Override
    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(getFullTableName(), row);
            result = executeUpdateReturnKeys(sh, row);
View Full Code Here

TOP

Related Classes of com.vaadin.data.util.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.