All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.jdbc.core.simple.SimpleJdbcOperations Maven / Gradle / Ivy

There is a newer version: 5.3.34
Show newest version
/*
 * Copyright 2002-2005 the original author or authors.
 *
 * 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.springframework.jdbc.core.simple;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcOperations;

/**
 * JDBC operations nterface usable on Java 5 and above, exposing a
 * set of common JDBC operations, whose interface is simplified
 * through the use of varargs and autoboxing.
 * 
 * @author Rod Johnson
 * @author Rob Harrop
 * @since 2.0
 * @see SimpleJdbcTemplate
 * @see org.springframework.jdbc.core.JdbcOperations
 */
public interface SimpleJdbcOperations {

	/**
	 * Expose the classic Spring JdbcTemplate to allow invocation of less
	 * commonly used methods.
	 */
	JdbcOperations getJdbcOperations();


	/**
	 * Query for an int passing in a SQL query and a variable
	 * number of arguments.
	 */
	int queryForInt(String sql, Object... args) throws DataAccessException;

	/**
	 * Query for an long passing in a SQL query and a variable
	 * number of arguments.
	 */
	long queryForLong(String sql, Object... args) throws DataAccessException;

	/**
	 * Query for an object of type T identified by the supplied @{@link Class}.
	 * @param sql the SQL query to run.
	 * @param requiredType the required type of the return value.
	 * @param args the args for the query.
	 * @see JdbcOperations#queryForObject(String, Class)
	 * @see JdbcOperations#queryForObject(String, Object[], Class)
	 */
	 T queryForObject(String sql, Class requiredType, Object... args)
			throws DataAccessException;

	/**
	 * Query for an object of type T using the supplied
	 * {@link ParameterizedRowMapper} to the query results to the object.
	 * @param sql the SQL query to run.
	 * @param rm the @{@link ParameterizedRowMapper} to use for result mapping
	 * @param args the args for the query.
	 * @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
	 * @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
	 */
	 T queryForObject(String sql, ParameterizedRowMapper rm, Object... args)
			throws DataAccessException;

	/**
	 * Query for a {@link List} of Objects of type T using
	 * the supplied {@link ParameterizedRowMapper} to the query results to the object.
	 * @param sql the SQL query to run.
	 * @param rm the @{@link ParameterizedRowMapper} to use for result mapping
	 * @param args the args for the query.
	 * @see JdbcOperations#queryForObject(String, org.springframework.jdbc.core.RowMapper)
	 * @see JdbcOperations#queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
	 */
	 List query(String sql, ParameterizedRowMapper rm, Object... args)
			throws DataAccessException;

	/**
	 * Execute the supplied query with the (optional) supplied arguments.
	 * 

The query is expected to be a single row query; the result row will be * mapped to a Map (one entry for each column, using the column name as the key). * @see JdbcOperations#queryForMap(String) * @see JdbcOperations#queryForMap(String, Object[]) */ Map queryForMap(String sql, Object... args) throws DataAccessException; /** * Execute the supplied query with the (optional) supplied arguments. *

Each element in the returned {@link List} is constructed as a {@link Map} * as described in {@link #queryForMap} * @see JdbcOperations#queryForList(String) * @see JdbcOperations#queryForList(String, Object[]) */ List> queryForList(String sql, Object... args) throws DataAccessException; /** * Executes the supplied SQL statement with (optional) supplied arguments. * @return the numbers of rows affected by the update. * @see JdbcOperations#update(String) * @see JdbcOperations#update(String, Object[]) */ int update(String sql, Object... args) throws DataAccessException; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy