Skip to content

Commit

Permalink
HHH-17511 - Fix for missing condition in join with a @SoftDelete mark…
Browse files Browse the repository at this point in the history
…ed Entity

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
  • Loading branch information
jrenaat authored and beikov committed Jan 4, 2024
1 parent f3bbaa2 commit 0721629
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.hibernate.HibernateException;
import org.hibernate.Internal;
import org.hibernate.LockMode;
import org.hibernate.boot.model.internal.SoftDeleteHelper;
import org.hibernate.boot.model.process.internal.InferredBasicValueResolver;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.TimestampaddFunction;
Expand Down Expand Up @@ -64,6 +65,7 @@
import org.hibernate.metamodel.mapping.Restrictable;
import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.metamodel.mapping.SelectableMappings;
import org.hibernate.metamodel.mapping.SoftDeleteMapping;
import org.hibernate.metamodel.mapping.SqlExpressible;
import org.hibernate.metamodel.mapping.SqlTypedMapping;
import org.hibernate.metamodel.mapping.ValueMapping;
Expand Down Expand Up @@ -3472,6 +3474,24 @@ private TableGroup consumeEntityJoin(SqmEntityJoin<?> sqmJoin, TableGroup lhsTab
);
lhsTableGroup.addTableGroupJoin( tableGroupJoin );

entityDescriptor.applyBaseRestrictions(
tableGroupJoin::applyPredicate,
tableGroup,
true,
getLoadQueryInfluencers().getEnabledFilters(),
null,
this
);

final SoftDeleteMapping softDeleteMapping = entityDescriptor.getSoftDeleteMapping();
if ( softDeleteMapping != null ) {
final Predicate softDeleteRestriction = SoftDeleteHelper.createNonSoftDeletedRestriction(
tableGroup.resolveTableReference( entityDescriptor.getSoftDeleteTableDetails().getTableName() ),
softDeleteMapping
);
tableGroupJoin.applyPredicate( softDeleteRestriction );
}

if ( sqmJoin.getJoinPredicate() != null ) {
final SqmJoin<?, ?> oldJoin = currentlyProcessingJoin;
currentlyProcessingJoin = sqmJoin;
Expand Down

0 comments on commit 0721629

Please sign in to comment.