当前位置: 首页>>代码示例>>Java>>正文


Java Delete类代码示例

本文整理汇总了Java中org.hibernate.sql.Delete的典型用法代码示例。如果您正苦于以下问题:Java Delete类的具体用法?Java Delete怎么用?Java Delete使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Delete类属于org.hibernate.sql包,在下文中一共展示了Delete类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateDeleteString

import org.hibernate.sql.Delete; //导入依赖的package包/类
/**
 * Generate the SQL DELETE that deletes all rows
 */
@Override
   protected String generateDeleteString() {
	
	Delete delete = new Delete()
			.setTableName( qualifiedTableName )
			.addPrimaryKeyColumns( keyColumnNames );
	
	if ( hasWhere ) delete.setWhere( sqlWhereString );
	
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		delete.setComment( "delete collection " + getRole() );
	}
	
	return delete.toStatementString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:BasicCollectionPersister.java

示例2: generateDeleteRowString

import org.hibernate.sql.Delete; //导入依赖的package包/类
/**
 * Generate the SQL DELETE that deletes a particular row
 */
@Override
   protected String generateDeleteRowString() {
	
	Delete delete = new Delete()
		.setTableName( qualifiedTableName );
	
	if ( hasIdentifier ) {
		delete.addPrimaryKeyColumns( new String[]{ identifierColumnName } );
	}
	else if ( hasIndex && !indexContainsFormula ) {
		delete.addPrimaryKeyColumns( ArrayHelper.join( keyColumnNames, indexColumnNames ) );
	}
	else {
		delete.addPrimaryKeyColumns( keyColumnNames );
		delete.addPrimaryKeyColumns( elementColumnNames, elementColumnIsInPrimaryKey, elementColumnWriters );
	}
	
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		delete.setComment( "delete collection row " + getRole() );
	}
	
	return delete.toStatementString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:BasicCollectionPersister.java

示例3: generateDeleteRowString

import org.hibernate.sql.Delete; //导入依赖的package包/类
/**
 * Generate the SQL DELETE that deletes a particular row
 */
protected String generateDeleteRowString() {
	
	Delete delete = new Delete()
		.setTableName( qualifiedTableName );
	
	if ( hasIdentifier ) {
		delete.setPrimaryKeyColumnNames( new String[]{ identifierColumnName } );
	}
	else if ( hasIndex && !indexContainsFormula ) {
		delete.setPrimaryKeyColumnNames( ArrayHelper.join( keyColumnNames, indexColumnNames ) );
	}
	else {
		delete.setPrimaryKeyColumnNames( ArrayHelper.join( keyColumnNames, elementColumnNames, elementColumnIsInPrimaryKey ) );
	}
	
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		delete.setComment( "delete collection row " + getRole() );
	}
	
	return delete.toStatementString();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:25,代码来源:BasicCollectionPersister.java

示例4: generateDeleteString

import org.hibernate.sql.Delete; //导入依赖的package包/类
/**
 * Generate the SQL that deletes a row by id (and version)
 */
protected String generateDeleteString(int j) {
	Delete delete = new Delete()
			.setTableName( getTableName( j ) )
			.addPrimaryKeyColumns( getKeyColumns( j ) );
	if ( j == 0 ) {
		delete.setVersionColumnName( getVersionColumnName() );
	}
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		delete.setComment( "delete " + getEntityName() );
	}
	return delete.toStatementString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:AbstractEntityPersister.java

示例5: generateSQLDeletStrings

import org.hibernate.sql.Delete; //导入依赖的package包/类
private String[] generateSQLDeletStrings(Object[] loadedState) {
	int span = getTableSpan();
	String[] deleteStrings = new String[span];
	for ( int j = span - 1; j >= 0; j-- ) {
		Delete delete = new Delete()
				.setTableName( getTableName( j ) )
				.addPrimaryKeyColumns( getKeyColumns( j ) );
		if ( getFactory().getSettings().isCommentsEnabled() ) {
			delete.setComment( "delete " + getEntityName() + " [" + j + "]" );
		}

		boolean[] versionability = getPropertyVersionability();
		Type[] types = getPropertyTypes();
		for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
			if ( isPropertyOfTable( i, j ) && versionability[i] ) {
				// this property belongs to the table and it is not specifically
				// excluded from optimistic locking by optimistic-lock="false"
				String[] propertyColumnNames = getPropertyColumnNames( i );
				boolean[] propertyNullness = types[i].toColumnNullness( loadedState[i], getFactory() );
				for ( int k = 0; k < propertyNullness.length; k++ ) {
					if ( propertyNullness[k] ) {
						delete.addWhereFragment( propertyColumnNames[k] + " = ?" );
					}
					else {
						delete.addWhereFragment( propertyColumnNames[k] + " is null" );
					}
				}
			}
		}
		deleteStrings[j] = delete.toStatementString();
	}
	return deleteStrings;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:AbstractEntityPersister.java

示例6: generateDelete

import org.hibernate.sql.Delete; //导入依赖的package包/类
private String generateDelete(String tableName, String[] columnNames, String idSubselect, String comment) {
	final Delete delete = new Delete()
			.setTableName( tableName )
			.setWhere( "(" + StringHelper.join( ", ", columnNames ) + ") IN (" + idSubselect + ")" );
	if ( factory().getSettings().isCommentsEnabled() ) {
		delete.setComment( comment );
	}
	return delete.toStatementString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:TableBasedDeleteHandlerImpl.java

示例7: generateDeleteString

import org.hibernate.sql.Delete; //导入依赖的package包/类
/**
 * Generate the SQL that deletes a row by id (and version)
 */
protected String generateDeleteString(int j) {
	Delete delete = new Delete()
			.setTableName( getTableName( j ) )
			.setPrimaryKeyColumnNames( getKeyColumns( j ) );
	if ( j == 0 ) {
		delete.setVersionColumnName( getVersionColumnName() );
	}
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		delete.setComment( "delete " + getEntityName() );
	}
	return delete.toStatementString();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:16,代码来源:AbstractEntityPersister.java

示例8: generateSQLDeletStrings

import org.hibernate.sql.Delete; //导入依赖的package包/类
private String[] generateSQLDeletStrings(Object[] loadedState) {
	int span = getTableSpan();
	String[] deleteStrings = new String[span];
	for ( int j = span - 1; j >= 0; j-- ) {
		Delete delete = new Delete()
				.setTableName( getTableName( j ) )
				.setPrimaryKeyColumnNames( getKeyColumns( j ) );
		if ( getFactory().getSettings().isCommentsEnabled() ) {
			delete.setComment( "delete " + getEntityName() + " [" + j + "]" );
		}

		boolean[] versionability = getPropertyVersionability();
		Type[] types = getPropertyTypes();
		for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
			if ( isPropertyOfTable( i, j ) && versionability[i] ) {
				// this property belongs to the table and it is not specifically
				// excluded from optimistic locking by optimistic-lock="false"
				String[] propertyColumnNames = getPropertyColumnNames( i );
				boolean[] propertyNullness = types[i].toColumnNullness( loadedState[i], getFactory() );
				for ( int k = 0; k < propertyNullness.length; k++ ) {
					if ( propertyNullness[k] ) {
						delete.addWhereFragment( propertyColumnNames[k] + " = ?" );
					}
					else {
						delete.addWhereFragment( propertyColumnNames[k] + " is null" );
					}
				}
			}
		}
		deleteStrings[j] = delete.toStatementString();
	}
	return deleteStrings;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:34,代码来源:AbstractEntityPersister.java

示例9: generateDeleteString

import org.hibernate.sql.Delete; //导入依赖的package包/类
/**
 * Generate the SQL DELETE that deletes all rows
 */
protected String generateDeleteString() {
	
	Delete delete = new Delete()
			.setTableName( qualifiedTableName )
			.setPrimaryKeyColumnNames( keyColumnNames );
	
	if ( hasWhere ) delete.setWhere( sqlWhereString );
	
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		delete.setComment( "delete collection " + getRole() );
	}
	
	return delete.toStatementString();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:BasicCollectionPersister.java

示例10: MultiTableDeleteExecutor

import org.hibernate.sql.Delete; //导入依赖的package包/类
public MultiTableDeleteExecutor(HqlSqlWalker walker) {
	super( walker, log );

	if ( !walker.getSessionFactoryHelper().getFactory().getDialect().supportsTemporaryTables() ) {
		throw new HibernateException( "cannot perform multi-table deletes using dialect not supporting temp tables" );
	}

	DeleteStatement deleteStatement = ( DeleteStatement ) walker.getAST();
	FromElement fromElement = deleteStatement.getFromClause().getFromElement();
	String bulkTargetAlias = fromElement.getTableAlias();
	this.persister = fromElement.getQueryable();

	this.idInsertSelect = generateIdInsertSelect( persister, bulkTargetAlias, deleteStatement.getWhereClause() );
	log.trace( "Generated ID-INSERT-SELECT SQL (multi-table delete) : " +  idInsertSelect );

	String[] tableNames = persister.getConstraintOrderedTableNameClosure();
	String[][] columnNames = persister.getContraintOrderedTableKeyColumnClosure();
	String idSubselect = generateIdSubselect( persister );

	deletes = new String[tableNames.length];
	for ( int i = tableNames.length - 1; i >= 0; i-- ) {
		// TODO : an optimization here would be to consider cascade deletes and not gen those delete statements;
		//      the difficulty is the ordering of the tables here vs the cascade attributes on the persisters ->
		//          the table info gotten here should really be self-contained (i.e., a class representation
		//          defining all the needed attributes), then we could then get an array of those
		final Delete delete = new Delete()
				.setTableName( tableNames[i] )
				.setWhere( "(" + StringHelper.join( ", ", columnNames[i] ) + ") IN (" + idSubselect + ")" );
		if ( getFactory().getSettings().isCommentsEnabled() ) {
			delete.setComment( "bulk delete" );
		}

		deletes[i] = delete.toStatementString();
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:36,代码来源:MultiTableDeleteExecutor.java

示例11: generateDelete

import org.hibernate.sql.Delete; //导入依赖的package包/类
private String generateDelete(String tableName, String[] columnNames,
							  String idSubselect, String comment) {
	final Delete delete = new Delete().setTableName( tableName).setWhere(
			"(" + StringHelper.join( ", ", columnNames) + ") IN ("
					+ idSubselect + ")");
	if (factory().getSettings().isCommentsEnabled()) {
		delete.setComment(comment);
	}
	return delete.toStatementString();
}
 
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:11,代码来源:CTEBasedDeleteHandlerImpl.java

示例12: generateDelete

import org.hibernate.sql.Delete; //导入依赖的package包/类
private String generateDelete(String tableName, String[] columnNames,
		String idSubselect, String comment) {
	final Delete delete = new Delete().setTableName(tableName).setWhere(
			"(" + StringHelper.join(", ", columnNames) + ") IN ("
					+ idSubselect + ")");
	if (factory().getSettings().isCommentsEnabled()) {
		delete.setComment(comment);
	}
	return delete.toStatementString();
}
 
开发者ID:epiresdasilva,项目名称:cte-multi-table-bulk-id-stategy,代码行数:11,代码来源:CTEBasedDeleteHandlerImpl.java

示例13: DeleteExecutor

import org.hibernate.sql.Delete; //导入依赖的package包/类
public DeleteExecutor(HqlSqlWalker walker, Queryable persister) {
	super( walker, persister );
	
	final SessionFactoryImplementor factory = walker.getSessionFactoryHelper().getFactory();
	final Dialect dialect = factory.getDialect();
	
	try {
		final DeleteStatement deleteStatement = (DeleteStatement) walker.getAST();
		
		final String idSubselectWhere;
		if ( deleteStatement.hasWhereClause() ) {
			final AST whereClause = deleteStatement.getWhereClause();
			final SqlGenerator gen = new SqlGenerator( factory );
			gen.whereClause( whereClause );
			parameterSpecifications = gen.getCollectedParameters();
			idSubselectWhere = gen.getSQL().length() > 7 ? gen.getSQL() : "";
		}
		else {
			parameterSpecifications = new ArrayList<ParameterSpecification>();
			idSubselectWhere = "";
		}
		
		// If many-to-many, delete the FK row in the collection table.
		for ( Type type : persister.getPropertyTypes() ) {
			if ( type.isCollectionType() ) {
				final CollectionType cType = (CollectionType) type;
				final AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory
						.getCollectionPersister( cType.getRole() );
				if ( cPersister.isManyToMany() ) {
					if ( persister.getIdentifierColumnNames().length > 1
							&& !dialect.supportsTuplesInSubqueries() ) {
						LOG.warn(
								"This dialect is unable to cascade the delete into the many-to-many join table" +
								" when the entity has multiple primary keys.  Either properly setup cascading on" +
								" the constraints or manually clear the associations prior to deleting the entities."
						);
					}
					else {
						final String idSubselect = "(select "
								+ StringHelper.join( ", ", persister.getIdentifierColumnNames() ) + " from "
								+ persister.getTableName() + idSubselectWhere + ")";
						final String where = "(" + StringHelper.join( ", ", cPersister.getKeyColumnNames() )
								+ ") in " + idSubselect;
						final Delete delete = new Delete().setTableName( cPersister.getTableName() ).setWhere( where );
						if ( factory.getSettings().isCommentsEnabled() ) {
							delete.setComment( "delete FKs in join table" );
						}
						deletes.add( delete.toStatementString() );
					}
				}
			}
		}
	}
	catch (RecognitionException e) {
		throw new HibernateException( "Unable to delete the FKs in the join table!", e );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:58,代码来源:DeleteExecutor.java


注:本文中的org.hibernate.sql.Delete类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。