Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2004 - 2011 Brian McCallister
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.skife.jdbi.v2;
Used for INSERT, UPDATE, and DELETE statements
public class Update extends SQLStatement<Update>
    Update(Handle handle,
           StatementLocator locator,
           StatementRewriter statementRewriter,
           StatementBuilder statementBuilder,
           String sql,
           ConcreteStatementContext ctx,
           SQLLog log,
           TimingCollector timingCollector,
           Foreman foreman,
           ContainerFactoryRegistry containerFactoryRegistry)
    {
        super(new Binding(), locatorstatementRewriterhandlestatementBuildersqlctxlogtimingCollector, Collections.<StatementCustomizer>emptyList(), foremancontainerFactoryRegistry);
    }

    
Execute the statement

Returns:
the number of rows modified
    public int execute()
    {
        try {
            return this.internalExecute(new QueryResultMunger<Integer>() {
                public Integer munge(Statement resultsthrows SQLException
                {
                    return results.getUpdateCount();
                }
            });
        }
        finally {
            cleanup();
        }
    }

    
Execute the statement and returns any auto-generated keys. This requires the JDBC driver to support the java.sql.Statement.getGeneratedKeys() method.

Parameters:
mapper the mapper to generate the resulting key object
Returns:
the generated key or null if none was returned
    public <GeneratedKeyType> GeneratedKeys<GeneratedKeyType> executeAndReturnGeneratedKeys(final ResultSetMapper<GeneratedKeyType> mapper)
    {
        return this.internalExecute(new QueryResultMunger<GeneratedKeys<GeneratedKeyType>>() {
            public GeneratedKeys<GeneratedKeyType> munge(Statement resultsthrows SQLException
            {
                return new GeneratedKeys<GeneratedKeyType>(mapper,
                                                           Update.this,
                                                           results,
                                                           getContext(),
                                                           getContainerMapperRegistry());
            }
        });
    }
    {
        return executeAndReturnGeneratedKeys(new DefaultMapper());
    }
New to GrepCode? Check out our FAQ X