org.hibernate.engine.jdbc.spi.StatementPreparer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
Hibernate's core ORM functionality
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.engine.jdbc.spi;
import java.sql.PreparedStatement;
import java.sql.Statement;
import org.hibernate.ScrollMode;
/**
* Contracting for preparing SQL statements
*
* @author Steve Ebersole
* @author Brett Meyer
*/
public interface StatementPreparer {
/**
* Create a statement.
*
* @return the statement
*/
public Statement createStatement();
/**
* Prepare a statement.
*
* @param sql The SQL the statement to be prepared
*
* @return the prepared statement
*/
public PreparedStatement prepareStatement(String sql);
/**
* Prepare a statement.
*
* @param sql The SQL the statement to be prepared
* @param isCallable Whether to prepare as a callable statement.
*
* @return the prepared statement
*/
public PreparedStatement prepareStatement(String sql, boolean isCallable);
/**
* Prepare an INSERT statement, specifying how auto-generated (by the database) keys should be handled. Really this
* is a boolean, but JDBC opted to define it instead using 2 int constants:
* - {@link PreparedStatement#RETURN_GENERATED_KEYS}
* - {@link PreparedStatement#NO_GENERATED_KEYS}
*
* Generated keys are accessed afterwards via {@link java.sql.PreparedStatement#getGeneratedKeys}
*
* @param sql The INSERT SQL
* @param autoGeneratedKeys The autoGeneratedKeys flag
*
* @return the prepared statement
*
* @see java.sql.Connection#prepareStatement(String, int)
*/
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys);
/**
* Prepare an INSERT statement, specifying columns which are auto-generated values to be returned.
* Generated keys are accessed afterwards via {@link java.sql.PreparedStatement#getGeneratedKeys}
*
* @param sql - the SQL for the statement to be prepared
* @param columnNames The name of the columns to be returned in the generated keys result set.
*
* @return the prepared statement
*
* @see java.sql.Connection#prepareStatement(String, String[])
*/
public PreparedStatement prepareStatement(String sql, String[] columnNames);
/**
* Get a prepared statement for use in loading / querying.
*
* @param sql The SQL the statement to be prepared
* @param isCallable Whether to prepare as a callable statement.
* @param scrollMode (optional) scroll mode to be applied to the resulting result set; may be null to indicate
* no scrolling should be applied.
*
* @return the prepared statement
*/
public PreparedStatement prepareQueryStatement(String sql, boolean isCallable, ScrollMode scrollMode);
}