Fix determine join type for subclasses

This commit is contained in:
Andrea Boriero 2020-06-26 05:45:08 +01:00
parent 9d749a6608
commit d0f891fca5
7 changed files with 26 additions and 7 deletions

View File

@ -139,9 +139,7 @@ public interface EntityMappingType extends ManagedMappingType, Loadable {
EntityRowIdMapping getRowIdMapping();
default EntityDiscriminatorMapping getDiscriminatorMapping() {
throw new NotYetImplementedFor6Exception( getClass() );
}
EntityDiscriminatorMapping getDiscriminatorMapping(TableGroup tableGroup);
NaturalIdMapping getNaturalIdMapping();

View File

@ -1330,7 +1330,7 @@ public abstract class AbstractEntityPersister
);
return new TableReferenceJoin(
canUseInnerJoin ? SqlAstJoinType.INNER : SqlAstJoinType.LEFT,
determineSubclassTableJoinType( i, canUseInnerJoin, true, Collections.emptySet() ),
joinedTableReference,
generateJoinPredicate(
lhs,
@ -6233,7 +6233,7 @@ public abstract class AbstractEntityPersister
}
@Override
public EntityDiscriminatorMapping getDiscriminatorMapping() {
public EntityDiscriminatorMapping getDiscriminatorMapping(TableGroup tableGroup) {
return discriminatorMapping;
}

View File

@ -1215,6 +1215,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
);
}
@Override
public EntityDiscriminatorMapping getDiscriminatorMapping(TableGroup tableGroup) {
if ( explicitDiscriminatorColumnName == null ) {
CaseSearchedExpressionInfo info = getCaseSearchedExpression( tableGroup );
@ -1228,7 +1229,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
);
}
else {
return getDiscriminatorMapping();
return super.getDiscriminatorMapping( tableGroup );
}
}

View File

@ -162,7 +162,7 @@ public abstract class AbstractEntityResultGraphNode extends AbstractFetchParent
protected EntityDiscriminatorMapping getDiscriminatorMapping(
EntityMappingType entityDescriptor,
TableGroup entityTableGroup) {
return entityDescriptor.getDiscriminatorMapping();
return entityDescriptor.getDiscriminatorMapping( entityTableGroup );
}
@Override

View File

@ -43,6 +43,7 @@ import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityRowIdMapping;
@ -59,6 +60,7 @@ import org.hibernate.persister.spi.PersisterClassResolver;
import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.tuple.entity.EntityTuplizer;
@ -699,6 +701,11 @@ public class PersisterClassProviderTest {
return null;
}
@Override
public EntityDiscriminatorMapping getDiscriminatorMapping(TableGroup tableGroup) {
return null;
}
@Override
public NaturalIdMapping getNaturalIdMapping() {
return null;

View File

@ -43,6 +43,7 @@ import org.hibernate.mapping.PersistentClass;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityRowIdMapping;
@ -637,6 +638,11 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
return null;
}
@Override
public EntityDiscriminatorMapping getDiscriminatorMapping(TableGroup tableGroup) {
return null;
}
@Override
public NaturalIdMapping getNaturalIdMapping() {
return null;

View File

@ -47,6 +47,7 @@ import org.hibernate.internal.StaticFilterAliasGenerator;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityRowIdMapping;
@ -60,6 +61,7 @@ import org.hibernate.persister.entity.MultiLoadOptions;
import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.tuple.entity.EntityTuplizer;
@ -748,6 +750,11 @@ public class CustomPersister implements EntityPersister {
return null;
}
@Override
public EntityDiscriminatorMapping getDiscriminatorMapping(TableGroup tableGroup) {
return null;
}
@Override
public NaturalIdMapping getNaturalIdMapping() {
return null;