本文整理汇总了Java中org.hibernate.hql.internal.ast.tree.UpdateStatement类的典型用法代码示例。如果您正苦于以下问题:Java UpdateStatement类的具体用法?Java UpdateStatement怎么用?Java UpdateStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UpdateStatement类属于org.hibernate.hql.internal.ast.tree包,在下文中一共展示了UpdateStatement类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TableBasedUpdateHandlerImpl
import org.hibernate.hql.internal.ast.tree.UpdateStatement; //导入依赖的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()] );
}
}
}
示例2: postProcessUpdate
import org.hibernate.hql.internal.ast.tree.UpdateStatement; //导入依赖的package包/类
@Override
protected void postProcessUpdate(AST update) throws SemanticException {
UpdateStatement updateStatement = (UpdateStatement) update;
postProcessDML( updateStatement );
}
示例3: prepareVersioned
import org.hibernate.hql.internal.ast.tree.UpdateStatement; //导入依赖的package包/类
@Override
protected void prepareVersioned(AST updateNode, AST versioned) throws SemanticException {
UpdateStatement updateStatement = (UpdateStatement) updateNode;
FromClause fromClause = updateStatement.getFromClause();
if ( versioned != null ) {
// Make sure that the persister is versioned
Queryable persister = fromClause.getFromElement().getQueryable();
if ( !persister.isVersioned() ) {
throw new SemanticException( "increment option specified for update of non-versioned entity" );
}
VersionType versionType = persister.getVersionType();
if ( versionType instanceof UserVersionType ) {
throw new SemanticException( "user-defined version types not supported for increment option" );
}
AST eq = getASTFactory().create( HqlSqlTokenTypes.EQ, "=" );
AST versionPropertyNode = generateVersionPropertyNode( persister );
eq.setFirstChild( versionPropertyNode );
AST versionIncrementNode = null;
if ( isTimestampBasedVersion( versionType ) ) {
versionIncrementNode = getASTFactory().create( HqlSqlTokenTypes.PARAM, "?" );
ParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification( versionType );
( (ParameterNode) versionIncrementNode ).setHqlParameterSpecification( paramSpec );
parameters.add( 0, paramSpec );
}
else {
// Not possible to simply re-use the versionPropertyNode here as it causes
// OOM errors due to circularity :(
versionIncrementNode = getASTFactory().create( HqlSqlTokenTypes.PLUS, "+" );
versionIncrementNode.setFirstChild( generateVersionPropertyNode( persister ) );
versionIncrementNode.addChild( getASTFactory().create( HqlSqlTokenTypes.IDENT, "1" ) );
}
eq.addChild( versionIncrementNode );
evaluateAssignment( eq, persister, 0 );
AST setClause = updateStatement.getSetClause();
AST currentFirstSetElement = setClause.getFirstChild();
setClause.setFirstChild( eq );
eq.setNextSibling( currentFirstSetElement );
}
}
示例4: CTEBasedUpdateHandlerImpl
import org.hibernate.hql.internal.ast.tree.UpdateStatement; //导入依赖的package包/类
public CTEBasedUpdateHandlerImpl(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 ProcessedWhereClause processedWhereClause = processWhereClause(updateStatement
.getWhereClause());
this.idSelectParameterSpecifications = processedWhereClause
.getIdSelectParameterSpecifications();
final String bulkTargetAlias = fromElement.getTableAlias();
this.idSelect = generateIdSelect(targetedPersister,
bulkTargetAlias, processedWhereClause);
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()]);
}
}
}
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:66,代码来源:CTEBasedUpdateHandlerImpl.java
示例5: CTEBasedUpdateHandlerImpl
import org.hibernate.hql.internal.ast.tree.UpdateStatement; //导入依赖的package包/类
public CTEBasedUpdateHandlerImpl(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 ProcessedWhereClause processedWhereClause = processWhereClause(updateStatement
.getWhereClause());
this.idSelectParameterSpecifications = processedWhereClause
.getIdSelectParameterSpecifications();
final String bulkTargetAlias = fromElement.getTableAlias();
this.idSelect = generateIdSelect(targetedPersister,
bulkTargetAlias, processedWhereClause);
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()]);
}
}
}
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:66,代码来源:CTEBasedUpdateHandlerImpl.java