HHH-9282 : Revert HHH-9222 on 4.3 branch
This commit is contained in:
parent
365bfe99d8
commit
25575d2e7d
|
@ -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.RequiresDialectFeature;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.SkipLog;
|
||||
|
@ -1421,7 +1422,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
|
||||
{
|
||||
|
@ -1490,7 +1491,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