HHH-9282 : Revert HHH-9222 on master
This commit is contained in:
parent
10df4cc79d
commit
873f28f5e6
|
@ -79,28 +79,13 @@ public class DeleteExecutor extends BasicExecutor {
|
|||
idSubselectWhere = "";
|
||||
}
|
||||
|
||||
// find plural attributes defined for the entity being deleted...
|
||||
// If many-to-many, delete the FK row in the collection table.
|
||||
for ( Type type : persister.getPropertyTypes() ) {
|
||||
if ( ! type.isCollectionType() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if the plural attribute maps to a "collection table" we need
|
||||
// to remove the rows from that table corresponding to any
|
||||
// owners we are about to delete. "collection table" is
|
||||
// (unfortunately) indicated in a number of ways, but here we
|
||||
// are mainly concerned with:
|
||||
// 1) many-to-many mappings
|
||||
// 2) basic collection mappings
|
||||
if ( type.isCollectionType() ) {
|
||||
final CollectionType cType = (CollectionType) type;
|
||||
final AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory
|
||||
.getCollectionPersister( cType.getRole() );
|
||||
final boolean hasCollectionTable = cPersister.isManyToMany()
|
||||
|| !cPersister.getElementType().isAssociationType();
|
||||
if ( !hasCollectionTable ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( cPersister.isManyToMany() ) {
|
||||
if ( persister.getIdentifierColumnNames().length > 1
|
||||
&& !dialect.supportsTuplesInSubqueries() ) {
|
||||
LOG.warn(
|
||||
|
@ -108,9 +93,8 @@ public class DeleteExecutor extends BasicExecutor {
|
|||
" when the entity has multiple primary keys. Either properly setup cascading on" +
|
||||
" the constraints or manually clear the associations prior to deleting the entities."
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
else {
|
||||
final String idSubselect = "(select "
|
||||
+ StringHelper.join( ", ", persister.getIdentifierColumnNames() ) + " from "
|
||||
+ persister.getTableName() + idSubselectWhere + ")";
|
||||
|
@ -118,11 +102,14 @@ public class DeleteExecutor extends BasicExecutor {
|
|||
+ ") in " + idSubselect;
|
||||
final Delete delete = new Delete().setTableName( cPersister.getTableName() ).setWhere( where );
|
||||
if ( factory.getSettings().isCommentsEnabled() ) {
|
||||
delete.setComment( "bulk delete - collection table clean up (" + cPersister.getRole() + ")" );
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -83,39 +83,17 @@ public class TableBasedDeleteHandlerImpl
|
|||
final String idSubselect = generateIdSubselect( targetedPersister );
|
||||
deletes = new ArrayList<String>();
|
||||
|
||||
// find plural attributes defined for the entity being deleted...
|
||||
//
|
||||
// NOTE : this partially overlaps with DeleteExecutor, but it instead
|
||||
// uses the temp table in the idSubselect.
|
||||
// If many-to-many, delete the FK row in the collection table.
|
||||
// This partially overlaps with DeleteExecutor, but it instead uses the temp table in the idSubselect.
|
||||
for ( Type type : targetedPersister.getPropertyTypes() ) {
|
||||
if ( ! type.isCollectionType() ) {
|
||||
continue;
|
||||
if ( type.isCollectionType() ) {
|
||||
CollectionType cType = (CollectionType) type;
|
||||
AbstractCollectionPersister cPersister = (AbstractCollectionPersister)factory.getCollectionPersister( cType.getRole() );
|
||||
if ( cPersister.isManyToMany() ) {
|
||||
deletes.add( generateDelete( cPersister.getTableName(),
|
||||
cPersister.getKeyColumnNames(), idSubselect, "bulk delete - m2m join table cleanup"));
|
||||
}
|
||||
|
||||
final CollectionType cType = (CollectionType) type;
|
||||
final AbstractCollectionPersister cPersister = (AbstractCollectionPersister)factory.getCollectionPersister( cType.getRole() );
|
||||
|
||||
// if the plural attribute maps to a "collection table" we need
|
||||
// to remove the rows from that table corresponding to any
|
||||
// owners we are about to delete. "collection table" is
|
||||
// (unfortunately) indicated in a number of ways, but here we
|
||||
// are mainly concerned with:
|
||||
// 1) many-to-many mappings
|
||||
// 2) basic collection mappings
|
||||
final boolean hasCollectionTable = cPersister.isManyToMany()
|
||||
|| !cPersister.getElementType().isAssociationType();
|
||||
if ( !hasCollectionTable ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
deletes.add(
|
||||
generateDelete(
|
||||
cPersister.getTableName(),
|
||||
cPersister.getKeyColumnNames(),
|
||||
idSubselect,
|
||||
"bulk delete - collection table clean up (" + cPersister.getRole() + ")"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
String[] tableNames = targetedPersister.getConstraintOrderedTableNameClosure();
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.hibernate.jdbc.Work;
|
|||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
|
@ -1426,7 +1427,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-9222" )
|
||||
@FailureExpected( jiraKey = "HHH-9282", message = "failed because HHH-9222 was reverted by HHH-9282")
|
||||
public void testBulkDeleteOfEntityWithElementCollection() {
|
||||
// set up test data
|
||||
{
|
||||
|
@ -1495,7 +1496,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-9222" )
|
||||
@FailureExpected( jiraKey = "HHH-9282", message = "failed because HHH-9222 was reverted by HHH-9282")
|
||||
public void testBulkDeleteOfMultiTableEntityWithElementCollection() {
|
||||
// set up test data
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue