public Set<String> execute(final ConnectionResource _con)
        throws SQLException
    {
        final Set<String> ret = new HashSet<>();
        if (getIds().length > 1 || checkUpdateRequired(_con)) {
            final StringBuilder cmd = new StringBuilder()
                .append(Context.getDbType().getSQLPart(SQLPart.UPDATE)).append(" ")
                .append(Context.getDbType().getTableQuote())
                .append(getTableName())
                .append(Context.getDbType().getTableQuote()).append(" ")
                .append(Context.getDbType().getSQLPart(SQLPart.SET)).append(" ");

            // append SQL values
            boolean first = true;
            for (final ColumnWithSQLValue col : getColumnWithSQLValues())  {
                if (first)  {
                    first = false;
                } else  {
                    cmd.append(Context.getDbType().getSQLPart(SQLPart.COMMA));
                }
                cmd.append(Context.getDbType().getColumnQuote())
                    .append(col.getColumnName())
                    .append(Context.getDbType().getColumnQuote())
                    .append(Context.getDbType().getSQLPart(SQLPart.EQUAL))
                    .append(col.getSqlValue());
            }

            // append values
            for (final AbstractColumnWithValue<?> col : getColumnWithValues())  {
                if (first)  {
                    first = false;
                } else  {
                    cmd.append(Context.getDbType().getSQLPart(SQLPart.COMMA));
                }
                cmd.append(Context.getDbType().getColumnQuote())
                    .append(col.getColumnName())
                    .append(Context.getDbType().getColumnQuote())
                    .append(Context.getDbType().getSQLPart(SQLPart.EQUAL))
                    .append("?");
                ret.add(col.getColumnName());
            }

            // append where clause
            cmd.append(" ").append(Context.getDbType().getSQLPart(SQLPart.WHERE)).append(" ")
                .append(Context.getDbType().getColumnQuote())
                .append(getIdColumn())
                .append(Context.getDbType().getColumnQuote());

            if (this.ids.length == 1) {
                cmd.append(Context.getDbType().getSQLPart(SQLPart.EQUAL))
                    .append("?");
            } else {
                cmd.append(" ").append(Context.getDbType().getSQLPart(SQLPart.IN)).append(" ")
                    .append(Context.getDbType().getSQLPart(SQLPart.PARENTHESIS_OPEN));
                first = true;
                for (@SuppressWarnings("unused") final long id : this.ids) {
                    if (first)  {
                        first = false;
                    } else  {
                        cmd.append(Context.getDbType().getSQLPart(SQLPart.COMMA));
                    }
                    cmd.append("?");
                }
                cmd.append(Context.getDbType().getSQLPart(SQLPart.PARENTHESIS_CLOSE));
            }

            if (SQLUpdate.LOG.isDebugEnabled()) {
                SQLUpdate.LOG.debug(cmd.toString());
            }

            final PreparedStatement stmt = _con.prepareStatement(cmd.toString());
            int index = 1;
            for (final AbstractColumnWithValue<?> col : getColumnWithValues())  {
                if (SQLUpdate.LOG.isDebugEnabled()) {
                    SQLUpdate.LOG.debug("    " + index + " = " + col.getValue());
                }
                col.set(index++, stmt);
            }

            for (final long id : this.ids) {
                SQLUpdate.LOG.debug("    " + index + " = " + id);
                stmt.setLong(index++, id);
            }

            try  {
                final int rows = stmt.executeUpdate();
                if (rows == 0) {
                    throw new SQLException("Object for SQL table '" + getTableName()
                            + "' with ids '" + this.ids + "' does not exists and was not updated.");
                }
            } finally  {
                stmt.close();
            }
        }
        return ret;
    }
public Set < String > execute ( final ConnectionResource _con ) throws SQLException { final Set < String > ret = new HashSet < > ( ) ; if ( getIds ( ) . length > 1 || checkUpdateRequired ( _con ) ) { final StringBuilder cmd = new StringBuilder ( ) . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . UPDATE ) ) . append ( " " ) . append ( Context . getDbType ( ) . getTableQuote ( ) ) . append ( getTableName ( ) ) . append ( Context . getDbType ( ) . getTableQuote ( ) ) . append ( " " ) . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . SET ) ) . append ( " " ) ; boolean first = true ; for ( final ColumnWithSQLValue col : getColumnWithSQLValues ( ) ) { if ( first ) { first = false ; } else { cmd . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . COMMA ) ) ; } cmd . append ( Context . getDbType ( ) . getColumnQuote ( ) ) . append ( col . getColumnName ( ) ) . append ( Context . getDbType ( ) . getColumnQuote ( ) ) . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . EQUAL ) ) . append ( col . getSqlValue ( ) ) ; } for ( final AbstractColumnWithValue < ? > col : getColumnWithValues ( ) ) { if ( first ) { first = false ; } else { cmd . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . COMMA ) ) ; } cmd . append ( Context . getDbType ( ) . getColumnQuote ( ) ) . append ( col . getColumnName ( ) ) . append ( Context . getDbType ( ) . getColumnQuote ( ) ) . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . EQUAL ) ) . append ( "?" ) ; ret . add ( col . getColumnName ( ) ) ; } cmd . append ( " " ) . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . WHERE ) ) . append ( " " ) . append ( Context . getDbType ( ) . getColumnQuote ( ) ) . append ( getIdColumn ( ) ) . append ( Context . getDbType ( ) . getColumnQuote ( ) ) ; if ( this . ids . length == 1 ) { cmd . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . EQUAL ) ) . append ( "?" ) ; } else { cmd . append ( " " ) . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . IN ) ) . append ( " " ) . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . PARENTHESIS_OPEN ) ) ; first = true ; for ( @ SuppressWarnings ( "unused" ) final long id : this . ids ) { if ( first ) { first = false ; } else { cmd . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . COMMA ) ) ; } cmd . append ( "?" ) ; } cmd . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . PARENTHESIS_CLOSE ) ) ; } if ( SQLUpdate . LOG . isDebugEnabled ( ) ) { SQLUpdate . LOG . debug ( cmd . toString ( ) ) ; } final PreparedStatement stmt = _con . prepareStatement ( cmd . toString ( ) ) ; int index = 1 ; for ( final AbstractColumnWithValue < ? > col : getColumnWithValues ( ) ) { if ( SQLUpdate . LOG . isDebugEnabled ( ) ) { SQLUpdate . LOG . debug ( "    " + index + " = " + col . getValue ( ) ) ; } col . set ( index ++ , stmt ) ; } for ( final long id : this . ids ) { SQLUpdate . LOG . debug ( "    " + index + " = " + id ) ; stmt . setLong ( index ++ , id ) ; } try { final int rows = stmt . executeUpdate ( ) ; if ( rows == 0 ) { throw new SQLException ( "Object for SQL table '" + getTableName ( ) + "' with ids '" + this . ids + "' does not exists and was not updated." ) ; } } finally { stmt . close ( ) ; } } return ret ; }
Executes the SQL update.

@param _con      SQL connection
@return the set< string>
@throws SQLException if update failed or the row for given {@link #id}
does not exists