Skip to content

Commit c83fd30

Browse files
stliusebersole
authored andcommitted
HHH-8276 - Integrate LoadPlans into UniqueEntityLoader (PoC)
1 parent 6f8fddd commit c83fd30

15 files changed

+32
-42
lines changed

hibernate-core/src/main/java/org/hibernate/LockMode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public enum LockMode {
8484
WRITE( 10 ),
8585

8686
/**
87-
* Similiar to {@link #UPGRADE} except that, for versioned entities,
87+
* Similar to {@link #UPGRADE} except that, for versioned entities,
8888
* it results in a forced version increment.
8989
*
9090
* @deprecated instead use PESSIMISTIC_FORCE_INCREMENT
@@ -97,13 +97,13 @@ public enum LockMode {
9797
*/
9898

9999
/**
100-
* Optimisticly assume that transaction will not experience contention for
100+
* Optimistically assume that transaction will not experience contention for
101101
* entities. The entity version will be verified near the transaction end.
102102
*/
103103
OPTIMISTIC( 6 ),
104104

105105
/**
106-
* Optimisticly assume that transaction will not experience contention for
106+
* Optimistically assume that transaction will not experience contention for
107107
* entities. The entity version will be verified and incremented near the transaction end.
108108
*/
109109
OPTIMISTIC_FORCE_INCREMENT( 7 ),

hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public boolean hasEnabledFetchProfiles() {
170170
return !enabledFetchProfileNames.isEmpty();
171171
}
172172

173-
public Set getEnabledFetchProfileNames() {
173+
public Set<String> getEnabledFetchProfileNames() {
174174
return enabledFetchProfileNames;
175175
}
176176

hibernate-core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,7 @@ protected final boolean isJoinFetchEnabledByProfile(OuterJoinLoadable persister,
172172
: rootPropertyName;
173173
String fetchRole = persister.getEntityName() + "." + relativePropertyPath;
174174

175-
Iterator profiles = getLoadQueryInfluencers().getEnabledFetchProfileNames().iterator();
176-
while ( profiles.hasNext() ) {
177-
final String profileName = ( String ) profiles.next();
175+
for ( String profileName : getLoadQueryInfluencers().getEnabledFetchProfileNames() ) {
178176
final FetchProfile profile = getFactory().getFetchProfile( profileName );
179177
final Fetch fetch = profile.getFetchByRole( fetchRole );
180178
if ( fetch != null && Fetch.Style.JOIN == fetch.getStyle() ) {

hibernate-core/src/main/java/org/hibernate/loader/entity/plan/LegacyBatchingEntityLoaderBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected UniqueEntityLoader buildBatchingLoader(
6363
return new LegacyBatchingEntityLoader( persister, batchSize, lockOptions, factory, influencers );
6464
}
6565

66-
public static class LegacyBatchingEntityLoader extends BatchingEntityLoader implements UniqueEntityLoader {
66+
public static class LegacyBatchingEntityLoader extends BatchingEntityLoader {
6767
private final int[] batchSizes;
6868
private final EntityLoader[] loaders;
6969

hibernate-core/src/main/java/org/hibernate/loader/plan/internal/SingleRootReturnLoadPlanBuilderStrategy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
* @author Steve Ebersole
5656
*/
5757
public class SingleRootReturnLoadPlanBuilderStrategy
58-
extends AbstractLoadPlanBuilderStrategy
59-
implements LoadPlanBuilderStrategy {
58+
extends AbstractLoadPlanBuilderStrategy {
6059

6160
private final LoadQueryInfluencers loadQueryInfluencers;
6261

hibernate-core/src/main/java/org/hibernate/loader/plan2/build/internal/FetchStyleLoadPlanBuildingAssociationVisitationStrategy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
* @author Steve Ebersole
5151
*/
5252
public class FetchStyleLoadPlanBuildingAssociationVisitationStrategy
53-
extends AbstractLoadPlanBuildingAssociationVisitationStrategy
54-
implements LoadPlanBuildingAssociationVisitationStrategy {
53+
extends AbstractLoadPlanBuildingAssociationVisitationStrategy {
5554
private static final Logger log = CoreLogging.logger( FetchStyleLoadPlanBuildingAssociationVisitationStrategy.class );
5655

5756
private final LoadQueryInfluencers loadQueryInfluencers;

hibernate-core/src/main/java/org/hibernate/loader/plan2/build/internal/spaces/QuerySpacesImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
/**
4444
* @author Steve Ebersole
4545
*/
46-
public class QuerySpacesImpl implements QuerySpaces, ExpandingQuerySpaces {
46+
public class QuerySpacesImpl implements ExpandingQuerySpaces {
4747
private static final Logger log = CoreLogging.logger( QuerySpacesImpl.class );
4848

4949
private final SessionFactoryImplementor sessionFactory;

hibernate-core/src/main/java/org/hibernate/loader/plan2/build/spi/LoadPlanTreePrinter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public class LoadPlanTreePrinter {
5353
*/
5454
public static final LoadPlanTreePrinter INSTANCE = new LoadPlanTreePrinter();
5555

56-
public String toString(LoadPlan loadPlan) {
56+
private String toString(LoadPlan loadPlan) {
5757
return toString( loadPlan, null );
5858
}
5959

60-
public String toString(LoadPlan loadPlan, AliasResolutionContextImpl aliasResolutionContext) {
60+
private String toString(LoadPlan loadPlan, AliasResolutionContextImpl aliasResolutionContext) {
6161
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
6262
final PrintStream printStream = new PrintStream( byteArrayOutputStream );
6363
final PrintWriter printWriter = new PrintWriter( printStream );
@@ -83,8 +83,9 @@ public void logTree(LoadPlan loadPlan, AliasResolutionContextImpl aliasResolutio
8383

8484
printWriter.flush();
8585
printStream.flush();
86+
log.debug( new String( byteArrayOutputStream.toByteArray() ) );
8687

87-
log.debug( toString( loadPlan, aliasResolutionContext ) );
88+
// log.debug( toString( loadPlan, aliasResolutionContext ) );
8889
}
8990

9091
private void logTree(

hibernate-core/src/main/java/org/hibernate/loader/plan2/build/spi/QuerySpaceTreePrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private void writeQuerySpace(
102102
writeJoins( querySpace.getJoins(), depth + 1, aliasResolutionContext, printWriter );
103103
}
104104

105-
final int detailDepthOffset = 4;
105+
final int detailDepthOffset = 1;
106106

107107
private void generateDetailLines(
108108
QuerySpace querySpace,

hibernate-core/src/main/java/org/hibernate/loader/plan2/exec/process/internal/ResultSetProcessorHelper.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,14 @@ public EntityKey interpretEntityKey(
6464
else {
6565
entityPersister = session.getFactory().getEntityPersister( optionalEntityName );
6666
}
67-
if ( entityPersister.isInstance( optionalId ) ) {
67+
if ( entityPersister.isInstance( optionalId ) && !entityPersister.getEntityMetamodel()
68+
.getIdentifierProperty()
69+
.isVirtual() && entityPersister.getEntityMetamodel().getIdentifierProperty().isEmbedded() ) {
6870
// embedded (non-encapsulated) composite identifier
69-
final Serializable identifierState = ( (CompositeType) entityPersister.getIdentifierType() ).getPropertyValues( optionalId, session );
71+
final Serializable identifierState = ((CompositeType) entityPersister.getIdentifierType()).getPropertyValues(
72+
optionalId,
73+
session
74+
);
7075
return session.generateEntityKey( identifierState, entityPersister );
7176
}
7277
else {

0 commit comments

Comments
 (0)