本文整理汇总了Java中org.hibernate.param.ParameterSpecification类的典型用法代码示例。如果您正苦于以下问题:Java ParameterSpecification类的具体用法?Java ParameterSpecification怎么用?Java ParameterSpecification使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParameterSpecification类属于org.hibernate.param包,在下文中一共展示了ParameterSpecification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processWhereClause
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected ProcessedWhereClause processWhereClause(AST whereClause) {
if ( whereClause.getNumberOfChildren() != 0 ) {
// If a where clause was specified in the update/delete query, use it to limit the
// returned ids here...
try {
SqlGenerator sqlGenerator = new SqlGenerator( sessionFactory );
sqlGenerator.whereClause( whereClause );
String userWhereClause = sqlGenerator.getSQL().substring( 7 ); // strip the " where "
List<ParameterSpecification> idSelectParameterSpecifications = sqlGenerator.getCollectedParameters();
return new ProcessedWhereClause( userWhereClause, idSelectParameterSpecifications );
}
catch ( RecognitionException e ) {
throw new HibernateException( "Unable to generate id select for DML operation", e );
}
}
else {
return ProcessedWhereClause.NO_WHERE_CLAUSE;
}
}
示例2: out
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
@Override
protected void out(AST n) {
if ( n instanceof Node ) {
out( ( (Node) n ).getRenderText( sessionFactory ) );
}
else {
super.out( n );
}
if ( n instanceof ParameterNode ) {
collectedParameters.add( ( (ParameterNode) n ).getHqlParameterSpecification() );
}
else if ( n instanceof ParameterContainer ) {
if ( ( (ParameterContainer) n ).hasEmbeddedParameters() ) {
ParameterSpecification[] specifications = ( (ParameterContainer) n ).getEmbeddedParameters();
if ( specifications != null ) {
collectedParameters.addAll( Arrays.asList( specifications ) );
}
}
}
}
示例3: processWhereClause
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected ProcessedWhereClause processWhereClause(AST whereClause) {
if (whereClause.getNumberOfChildren() != 0) {
// If a where clause was specified in the update/delete query, use
// it to limit the
// returned ids here...
try {
SqlGenerator sqlGenerator = new SqlGenerator( sessionFactory);
sqlGenerator.whereClause(whereClause);
String userWhereClause = sqlGenerator.getSQL().substring( 7); // strip
// the
// " where "
List<ParameterSpecification> idSelectParameterSpecifications = sqlGenerator
.getCollectedParameters();
return new ProcessedWhereClause(userWhereClause,
idSelectParameterSpecifications);
} catch (RecognitionException e) {
throw new HibernateException(
"Unable to generate id select for DML operation", e);
}
} else {
return ProcessedWhereClause.NO_WHERE_CLAUSE;
}
}
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:25,代码来源:AbstractCTEBasedBulkIdHandler.java
示例4: processWhereClause
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected ProcessedWhereClause processWhereClause(AST whereClause) {
if (whereClause.getNumberOfChildren() != 0) {
// If a where clause was specified in the update/delete query, use
// it to limit the
// returned ids here...
try {
SqlGenerator sqlGenerator = new SqlGenerator(sessionFactory);
sqlGenerator.whereClause(whereClause);
String userWhereClause = sqlGenerator.getSQL().substring(7); // strip
// the
// " where "
List<ParameterSpecification> idSelectParameterSpecifications = sqlGenerator
.getCollectedParameters();
return new ProcessedWhereClause(userWhereClause,
idSelectParameterSpecifications);
} catch (RecognitionException e) {
throw new HibernateException(
"Unable to generate id select for DML operation", e);
}
} else {
return ProcessedWhereClause.NO_WHERE_CLAUSE;
}
}
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:25,代码来源:AbstractCTEBasedBulkIdHandler.java
示例5: 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;
}
示例6: 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;
}
示例7: collectDisplayInfo
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
private String collectDisplayInfo() {
StringBuilder buffer = new StringBuilder();
for ( ParameterSpecification paramSpec : paramSpecs ) {
buffer.append( ( paramSpec ).renderDisplayInfo() );
}
return buffer.toString();
}
示例8: mutateRowValueConstructorSyntax
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
/**
* Mutate the subtree relating to a row-value-constructor to instead use
* a series of ANDed predicates. This allows multi-column type comparisons
* and explicit row-value-constructor syntax even on databases which do
* not support row-value-constructor.
* <p/>
* For example, here we'd mutate "... where (col1, col2) = ('val1', 'val2) ..." to
* "... where col1 = 'val1' and col2 = 'val2' ..."
*
* @param valueElements The number of elements in the row value constructor list.
*/
private void mutateRowValueConstructorSyntax(int valueElements) {
// mutation depends on the types of nodes involved...
int comparisonType = getType();
String comparisonText = getText();
setType( HqlSqlTokenTypes.AND );
setText( "AND" );
String[] lhsElementTexts = extractMutationTexts( getLeftHandOperand(), valueElements );
String[] rhsElementTexts = extractMutationTexts( getRightHandOperand(), valueElements );
ParameterSpecification lhsEmbeddedCompositeParameterSpecification =
getLeftHandOperand() == null || ( !ParameterNode.class.isInstance( getLeftHandOperand() ) )
? null
: ( (ParameterNode) getLeftHandOperand() ).getHqlParameterSpecification();
ParameterSpecification rhsEmbeddedCompositeParameterSpecification =
getRightHandOperand() == null || ( !ParameterNode.class.isInstance( getRightHandOperand() ) )
? null
: ( (ParameterNode) getRightHandOperand() ).getHqlParameterSpecification();
translate(
valueElements,
comparisonType,
comparisonText,
lhsElementTexts,
rhsElementTexts,
lhsEmbeddedCompositeParameterSpecification,
rhsEmbeddedCompositeParameterSpecification,
this
);
}
示例9: addEmbeddedParameter
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
@Override
public void addEmbeddedParameter(ParameterSpecification specification) {
if ( embeddedParameters == null ) {
embeddedParameters = new ArrayList<ParameterSpecification>();
}
embeddedParameters.add( specification );
}
示例10: setIndexCollectionSelectorParamSpec
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
public void setIndexCollectionSelectorParamSpec(ParameterSpecification indexCollectionSelectorParamSpec) {
if ( indexCollectionSelectorParamSpec == null ) {
if ( elementType.getIndexCollectionSelectorParamSpec() != null ) {
embeddedParameters.remove( elementType.getIndexCollectionSelectorParamSpec() );
elementType.setIndexCollectionSelectorParamSpec( null );
}
}
else {
elementType.setIndexCollectionSelectorParamSpec( indexCollectionSelectorParamSpec );
addEmbeddedParameter( indexCollectionSelectorParamSpec );
}
}
示例11: 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 );
}
}
示例12: applyParameterSpecifications
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
private void applyParameterSpecifications(ParameterContainer parameterContainer) {
if ( parameterContainer.hasEmbeddedParameters() ) {
ParameterSpecification[] specs = parameterContainer.getEmbeddedParameters();
for ( ParameterSpecification spec : specs ) {
applyParameterSpecification( spec );
}
}
}
示例13: 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;
}
示例14: 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
);
}
}
示例15: TableBasedUpdateHandlerImpl
import org.hibernate.param.ParameterSpecification; //导入依赖的package包/类
public TableBasedUpdateHandlerImpl(
SessionFactoryImplementor factory,
HqlSqlWalker walker,
String catalog,
String schema) {
super( factory, walker, catalog, schema );
UpdateStatement updateStatement = ( UpdateStatement ) walker.getAST();
FromElement fromElement = updateStatement.getFromClause().getFromElement();
this.targetedPersister = fromElement.getQueryable();
final String bulkTargetAlias = fromElement.getTableAlias();
final ProcessedWhereClause processedWhereClause = processWhereClause( updateStatement.getWhereClause() );
this.idSelectParameterSpecifications = processedWhereClause.getIdSelectParameterSpecifications();
this.idInsertSelect = generateIdInsertSelect( targetedPersister, bulkTargetAlias, processedWhereClause );
log.tracev( "Generated ID-INSERT-SELECT SQL (multi-table update) : {0}", idInsertSelect );
String[] tableNames = targetedPersister.getConstraintOrderedTableNameClosure();
String[][] columnNames = targetedPersister.getContraintOrderedTableKeyColumnClosure();
String idSubselect = generateIdSubselect( targetedPersister );
updates = new String[tableNames.length];
assignmentParameterSpecifications = new ParameterSpecification[tableNames.length][];
for ( int tableIndex = 0; tableIndex < tableNames.length; tableIndex++ ) {
boolean affected = false;
final List<ParameterSpecification> parameterList = new ArrayList<ParameterSpecification>();
final Update update = new Update( factory().getDialect() )
.setTableName( tableNames[tableIndex] )
.setWhere( "(" + StringHelper.join( ", ", columnNames[tableIndex] ) + ") IN (" + idSubselect + ")" );
if ( factory().getSettings().isCommentsEnabled() ) {
update.setComment( "bulk update" );
}
final List<AssignmentSpecification> assignmentSpecifications = walker.getAssignmentSpecifications();
for ( AssignmentSpecification assignmentSpecification : assignmentSpecifications ) {
if ( assignmentSpecification.affectsTable( tableNames[tableIndex] ) ) {
affected = true;
update.appendAssignmentFragment( assignmentSpecification.getSqlAssignmentFragment() );
if ( assignmentSpecification.getParameters() != null ) {
for ( int paramIndex = 0; paramIndex < assignmentSpecification.getParameters().length; paramIndex++ ) {
parameterList.add( assignmentSpecification.getParameters()[paramIndex] );
}
}
}
}
if ( affected ) {
updates[tableIndex] = update.toStatementString();
assignmentParameterSpecifications[tableIndex] = parameterList.toArray( new ParameterSpecification[parameterList.size()] );
}
}
}