本文整理汇总了Java中org.hibernate.param.ParameterSpecification.bind方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterSpecification.bind方法的具体用法?Java ParameterSpecification.bind怎么用?Java ParameterSpecification.bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.param.ParameterSpecification
的用法示例。
在下文中一共展示了ParameterSpecification.bind方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindParameterValues
import org.hibernate.param.ParameterSpecification; //导入方法依赖的package包/类
/**
* We specifically override this method here, because in general we know much more
* about the parameters and their appropriate bind positions here then we do in
* our super because we track them explicitly here through the ParameterSpecification
* interface.
*
* @param queryParameters The encapsulation of the parameter values to be bound.
* @param startIndex The position from which to start binding parameter values.
* @param session The originating session.
* @return The number of JDBC bind positions actually bound during this method execution.
* @throws SQLException Indicates problems performing the binding.
*/
@Override
protected int bindParameterValues(
final PreparedStatement statement,
final QueryParameters queryParameters,
final int startIndex,
final SessionImplementor session) throws SQLException {
int position = startIndex;
List<ParameterSpecification> parameterSpecs = queryTranslator.getCollectedParameterSpecifications();
for ( ParameterSpecification spec : parameterSpecs ) {
position += spec.bind( statement, queryParameters, session, position );
}
return position - startIndex;
}
示例2: bind
import org.hibernate.param.ParameterSpecification; //导入方法依赖的package包/类
@Override
public int bind(PreparedStatement statement, QueryParameters qp, SessionImplementor session, int position)
throws SQLException {
int bindCount = 0;
for ( ParameterSpecification paramSpec : paramSpecs ) {
bindCount += paramSpec.bind( statement, qp, session, position + bindCount );
}
return bindCount;
}
示例3: doExecute
import org.hibernate.param.ParameterSpecification; //导入方法依赖的package包/类
protected int doExecute(QueryParameters parameters, SessionImplementor session, String sql,
List parameterSpecifications) throws HibernateException {
BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, persister );
if ( session.isEventSource() ) {
( (EventSource) session ).getActionQueue().addAction( action );
}
else {
action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session );
}
PreparedStatement st = null;
RowSelection selection = parameters.getRowSelection();
try {
try {
st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareStatement( sql, false );
Iterator paramSpecItr = parameterSpecifications.iterator();
int pos = 1;
while ( paramSpecItr.hasNext() ) {
final ParameterSpecification paramSpec = (ParameterSpecification) paramSpecItr.next();
pos += paramSpec.bind( st, parameters, session, pos );
}
if ( selection != null ) {
if ( selection.getTimeout() != null ) {
st.setQueryTimeout( selection.getTimeout() );
}
}
return session.getTransactionCoordinator().getJdbcCoordinator().getResultSetReturn().executeUpdate( st );
}
finally {
if ( st != null ) {
session.getTransactionCoordinator().getJdbcCoordinator().release( st );
}
}
}
catch( SQLException sqle ) {
throw factory.getSQLExceptionHelper().convert( sqle, "could not execute update query", sql );
}
}
示例4: bindParameterValues
import org.hibernate.param.ParameterSpecification; //导入方法依赖的package包/类
/**
* We specifically override this method here, because in general we know much more
* about the parameters and their appropriate bind positions here then we do in
* our super because we track them explciitly here through the ParameterSpecification
* interface.
*
* @param queryParameters The encapsulation of the parameter values to be bound.
* @param startIndex The position from which to start binding parameter values.
* @param session The originating session.
* @return The number of JDBC bind positions actually bound during this method execution.
* @throws SQLException Indicates problems performing the binding.
*/
protected int bindParameterValues(
final PreparedStatement statement,
final QueryParameters queryParameters,
final int startIndex,
final SessionImplementor session) throws SQLException {
int position = bindFilterParameterValues( statement, queryParameters, startIndex, session );
List parameterSpecs = queryTranslator.getSqlAST().getWalker().getParameters();
Iterator itr = parameterSpecs.iterator();
while ( itr.hasNext() ) {
ParameterSpecification spec = ( ParameterSpecification ) itr.next();
position += spec.bind( statement, queryParameters, session, position );
}
return position - startIndex;
}
示例5: execute
import org.hibernate.param.ParameterSpecification; //导入方法依赖的package包/类
public int execute(QueryParameters parameters, SessionImplementor session) throws HibernateException {
coordinateSharedCacheCleanup( session );
PreparedStatement st = null;
RowSelection selection = parameters.getRowSelection();
try {
try {
st = session.getBatcher().prepareStatement( sql );
Iterator paramSpecifications = getWalker().getParameters().iterator();
int pos = 1;
while ( paramSpecifications.hasNext() ) {
final ParameterSpecification paramSpec = ( ParameterSpecification ) paramSpecifications.next();
pos += paramSpec.bind( st, parameters, session, pos );
}
if ( selection != null ) {
if ( selection.getTimeout() != null ) {
st.setQueryTimeout( selection.getTimeout().intValue() );
}
}
return st.executeUpdate();
}
finally {
if ( st != null ) {
session.getBatcher().closeStatement( st );
}
}
}
catch( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
sqle,
"could not execute update query",
sql
);
}
}
示例6: prepareCteStatement
import org.hibernate.param.ParameterSpecification; //导入方法依赖的package包/类
private CTEValues prepareCteStatement(SessionImplementor session,
QueryParameters queryParameters) {
CTEValues values = new CTEValues();
PreparedStatement ps = null;
try {
try {
ps = session.getJdbcCoordinator()
.getStatementPreparer()
.prepareStatement(idSelect, false);
int sum = 1;
sum += handlePrependedParametersOnIdSelection(ps, session, sum);
for (ParameterSpecification parameterSpecification : idSelectParameterSpecifications) {
sum += parameterSpecification.bind(ps, queryParameters,
session, sum);
}
ResultSet rs = session
.getJdbcCoordinator().getResultSetReturn().extract(ps);
while (rs.next()) {
Object[] result = new Object[targetedPersister
.getIdentifierColumnNames().length];
for (String columnName : targetedPersister
.getIdentifierColumnNames()) {
Object column = rs.getObject( columnName);
result[rs.findColumn(columnName) - 1] = column;
}
values.getSelectResult().add(result);
}
if (values.getSelectResult().isEmpty()) {
return values;
}
String idCteSelect = generateIdCteSelect( targetedPersister,
determineIdTableName(targetedPersister),
values.getSelectResult());
values.setIdCteSelect(idCteSelect);
log.tracev(
"Generated ID-CTE-SELECT SQL (multi-table update) : {0}",
idCteSelect);
return values;
} finally {
if (ps != null) {
ps.close();
}
}
} catch (SQLException e) {
throw convert(e, "could not insert/select ids for bulk update",
idSelect);
}
}
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:55,代码来源:CTEBasedUpdateHandlerImpl.java
示例7: prepareCteStatement
import org.hibernate.param.ParameterSpecification; //导入方法依赖的package包/类
private CTEValues prepareCteStatement(SessionImplementor session,
QueryParameters queryParameters) {
CTEValues values = new CTEValues();
PreparedStatement ps = null;
try {
try {
ps = session.getJdbcCoordinator()
.getStatementPreparer()
.prepareStatement(idSelect, false);
int sum = 1;
sum += handlePrependedParametersOnIdSelection(ps, session, sum);
for (ParameterSpecification parameterSpecification : idSelectParameterSpecifications) {
sum += parameterSpecification.bind(ps, queryParameters,
session, sum);
}
ResultSet rs = session
.getJdbcCoordinator().getResultSetReturn().extract(ps);
while (rs.next()) {
Object[] result = new Object[targetedPersister
.getIdentifierColumnNames().length];
for (String columnName : targetedPersister
.getIdentifierColumnNames()) {
Object column = rs.getObject( columnName);
result[rs.findColumn(columnName) - 1] = column;
}
values.getSelectResult().add(result);
}
if (values.getSelectResult().isEmpty()) {
return values;
}
String idCteSelect = generateIdCteSelect( targetedPersister,
determineIdTableName(targetedPersister),
values.getSelectResult());
values.setIdCteSelect(idCteSelect);
log.tracev(
"Generated ID-CTE-SELECT SQL (multi-table delete) : {0}",
idCteSelect);
return values;
} finally {
if (ps != null) {
ps.close();
}
}
} catch (SQLException e) {
throw convert(e, "could not insert/select ids for bulk delete",
idSelect);
}
}
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:55,代码来源:CTEBasedDeleteHandlerImpl.java
示例8: prepareCteStatement
import org.hibernate.param.ParameterSpecification; //导入方法依赖的package包/类
private CTEValues prepareCteStatement(SessionImplementor session,
QueryParameters queryParameters) {
CTEValues values = new CTEValues();
PreparedStatement ps = null;
try {
try {
ps = session.getTransactionCoordinator().getJdbcCoordinator()
.getStatementPreparer()
.prepareStatement(idSelect, false);
int sum = 1;
sum += handlePrependedParametersOnIdSelection(ps, session, sum);
for (ParameterSpecification parameterSpecification : idSelectParameterSpecifications) {
sum += parameterSpecification.bind(ps, queryParameters,
session, sum);
}
ResultSet rs = session.getTransactionCoordinator()
.getJdbcCoordinator().getResultSetReturn().extract(ps);
while (rs.next()) {
Object[] result = new Object[targetedPersister
.getIdentifierColumnNames().length];
for (String columnName : targetedPersister
.getIdentifierColumnNames()) {
Object column = rs.getObject(columnName);
result[rs.findColumn(columnName) - 1] = column;
}
values.getSelectResult().add(result);
}
if (values.getSelectResult().isEmpty()) {
return values;
}
String idCteSelect = generateIdCteSelect(targetedPersister,
determineIdTableName(targetedPersister),
values.getSelectResult());
values.setIdCteSelect(idCteSelect);
log.tracev(
"Generated ID-CTE-SELECT SQL (multi-table update) : {0}",
idCteSelect);
return values;
} finally {
if (ps != null) {
session.getTransactionCoordinator().getJdbcCoordinator()
.release(ps);
}
}
} catch (SQLException e) {
throw convert(e, "could not insert/select ids for bulk update",
idSelect);
}
}
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:56,代码来源:CTEBasedUpdateHandlerImpl.java
示例9: prepareCteStatement
import org.hibernate.param.ParameterSpecification; //导入方法依赖的package包/类
private CTEValues prepareCteStatement(SessionImplementor session,
QueryParameters queryParameters) {
CTEValues values = new CTEValues();
PreparedStatement ps = null;
try {
try {
ps = session.getTransactionCoordinator().getJdbcCoordinator()
.getStatementPreparer()
.prepareStatement(idSelect, false);
int sum = 1;
sum += handlePrependedParametersOnIdSelection(ps, session, sum);
for (ParameterSpecification parameterSpecification : idSelectParameterSpecifications) {
sum += parameterSpecification.bind(ps, queryParameters,
session, sum);
}
ResultSet rs = session.getTransactionCoordinator()
.getJdbcCoordinator().getResultSetReturn().extract(ps);
while (rs.next()) {
Object[] result = new Object[targetedPersister
.getIdentifierColumnNames().length];
for (String columnName : targetedPersister
.getIdentifierColumnNames()) {
Object column = rs.getObject(columnName);
result[rs.findColumn(columnName) - 1] = column;
}
values.getSelectResult().add(result);
}
if (values.getSelectResult().isEmpty()) {
return values;
}
String idCteSelect = generateIdCteSelect(targetedPersister,
determineIdTableName(targetedPersister),
values.getSelectResult());
values.setIdCteSelect(idCteSelect);
log.tracev(
"Generated ID-CTE-SELECT SQL (multi-table delete) : {0}",
idCteSelect);
return values;
} finally {
if (ps != null) {
session.getTransactionCoordinator().getJdbcCoordinator()
.release(ps);
}
}
} catch (SQLException e) {
throw convert(e, "could not insert/select ids for bulk delete",
idSelect);
}
}
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:56,代码来源:CTEBasedDeleteHandlerImpl.java