From b70487546e772a2b4b655219764484741314c38e Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Thu, 4 Nov 2021 19:42:39 +0100 Subject: [PATCH] Code refactoring --- .../internal/FetchingScrollableResultsImpl.java | 16 +++------------- .../internal/CompoundNaturalIdMapping.java | 5 ----- .../sql/results/graph/FetchParentAccess.java | 2 -- .../internal/EmbeddableFetchInitializer.java | 5 ----- .../internal/EmbeddableResultInitializer.java | 6 ------ 5 files changed, 3 insertions(+), 31 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/FetchingScrollableResultsImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/FetchingScrollableResultsImpl.java index 9ae17c103c..441a85c9fa 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/FetchingScrollableResultsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/FetchingScrollableResultsImpl.java @@ -53,13 +53,9 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults< } private static EntityInitializer extractResultInitializer(RowReader rowReader) { - for ( Initializer initializer : rowReader.getInitializers() ) { - if ( initializer instanceof EntityInitializer ) { - EntityInitializer entityInitializer = (EntityInitializer) initializer; - if ( entityInitializer instanceof EntityResultInitializer ) { - return entityInitializer; - } - } + Initializer initializer = rowReader.getInitializers().get( rowReader.getInitializers().size() - 1 ); + if ( initializer instanceof EntityInitializer ) { + return (EntityInitializer) initializer; } return null; } @@ -123,9 +119,6 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults< // In the latter scenario, the previous logical row // really is the last logical row. // - // In all other cases, we should process back two - // logical records (the current logic row, plus the - // previous logical row). if ( getRowProcessingState().isAfterLast() && maxPosition != null && currentPosition > maxPosition ) { // position cursor to the last row getRowProcessingState().last(); @@ -138,7 +131,6 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults< // in skipping getRowProcessingState().previous(); -// getRowProcessingState().previous(); // sequentially read the result set in reverse until we recognize // a change in the key value. At that point, we are pointed at @@ -324,8 +316,6 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults< currentRow = rowReader.readRow( getRowProcessingState(), getProcessingOptions() ); -// currentRow = new Object[] {row}; - getRowProcessingState().finishRowProcessing(); while ( !resultProcessed ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java index 6fc34545cf..f504b581b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java @@ -605,11 +605,6 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement return navigablePath; } - @Override - public EntityKey getEntityKey() { - return null; - } - @Override public ModelPart getInitializedPart() { return naturalIdMapping; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParentAccess.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParentAccess.java index 6745d638c3..48f060cf1b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParentAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParentAccess.java @@ -27,8 +27,6 @@ public interface FetchParentAccess extends Initializer { NavigablePath getNavigablePath(); - EntityKey getEntityKey(); - /** * Register a listener to be notified when the parent is "resolved" * diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchInitializer.java index 17ecb52631..895a7f1b02 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchInitializer.java @@ -6,7 +6,6 @@ */ package org.hibernate.sql.results.graph.embeddable.internal; -import org.hibernate.engine.spi.EntityKey; import org.hibernate.sql.results.graph.AssemblerCreationState; import org.hibernate.sql.results.graph.FetchParentAccess; import org.hibernate.sql.results.graph.embeddable.AbstractEmbeddableInitializer; @@ -29,8 +28,4 @@ public class EmbeddableFetchInitializer return findFirstEntityDescriptorAccess().getParentKey(); } - @Override - public EntityKey getEntityKey() { - return findFirstEntityDescriptorAccess().getEntityKey(); - } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultInitializer.java index 838ff1715d..e19b69322f 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultInitializer.java @@ -6,7 +6,6 @@ */ package org.hibernate.sql.results.graph.embeddable.internal; -import org.hibernate.engine.spi.EntityKey; import org.hibernate.sql.results.graph.AssemblerCreationState; import org.hibernate.sql.results.graph.embeddable.AbstractEmbeddableInitializer; import org.hibernate.sql.results.graph.embeddable.EmbeddableResultGraphNode; @@ -26,11 +25,6 @@ public class EmbeddableResultInitializer extends AbstractEmbeddableInitializer { return findFirstEntityDescriptorAccess().getParentKey(); } - @Override - public EntityKey getEntityKey() { - return findFirstEntityDescriptorAccess().getEntityKey(); - } - @Override public String toString() { return "EmbeddableResultInitializer(" + getNavigablePath() + ")";