Skip to content

Commit 3200800

Browse files
committed
Align the signature of the method for multiloading natural id entities with the one for normal entity multiloading
Signed-off-by: Jan Schatteman <[email protected]>
1 parent 00e552e commit 3200800

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractMultiNaturalIdLoader.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.hibernate.engine.spi.EntityKey;
1111
import org.hibernate.engine.spi.PersistenceContext;
1212
import org.hibernate.engine.spi.SharedSessionContractImplementor;
13+
import org.hibernate.event.spi.EventSource;
1314
import org.hibernate.loader.ast.spi.MultiNaturalIdLoadOptions;
1415
import org.hibernate.loader.ast.spi.MultiNaturalIdLoader;
1516
import org.hibernate.metamodel.mapping.EntityMappingType;
@@ -31,7 +32,7 @@ public AbstractMultiNaturalIdLoader(EntityMappingType entityDescriptor) {
3132
}
3233

3334
@Override
34-
public <K> List<E> multiLoad(K[] naturalIds, MultiNaturalIdLoadOptions options, SharedSessionContractImplementor session) {
35+
public <K> List<E> multiLoad(K[] naturalIds, MultiNaturalIdLoadOptions options, EventSource eventSource) {
3536
assert naturalIds != null;
3637

3738
this.options = options;
@@ -41,41 +42,41 @@ public <K> List<E> multiLoad(K[] naturalIds, MultiNaturalIdLoadOptions options,
4142
}
4243

4344
return options.isOrderReturnEnabled()
44-
? performOrderedMultiLoad( naturalIds, options, session )
45-
: performUnorderedMultiLoad( naturalIds, options, session );
45+
? performOrderedMultiLoad( naturalIds, options, eventSource )
46+
: performUnorderedMultiLoad( naturalIds, options, eventSource );
4647
}
4748

48-
private <K> List<E> performUnorderedMultiLoad(K[] naturalIds, MultiNaturalIdLoadOptions options, SharedSessionContractImplementor session) {
49+
private <K> List<E> performUnorderedMultiLoad(K[] naturalIds, MultiNaturalIdLoadOptions options, EventSource eventSource) {
4950
if ( MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
5051
MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER.tracef( "Unordered MultiLoad Starting - `%s`", getEntityDescriptor().getEntityName() );
5152
}
5253

5354
return unorderedMultiLoad(
5455
naturalIds,
55-
session,
56+
eventSource,
5657
options.getLockOptions() == null ? LockOptions.NONE : options.getLockOptions()
5758
);
5859
}
5960

60-
protected abstract <K> List<E> unorderedMultiLoad(K[] naturalIds, SharedSessionContractImplementor session, LockOptions lockOptions);
61+
protected abstract <K> List<E> unorderedMultiLoad(K[] naturalIds, EventSource eventSource, LockOptions lockOptions);
6162

62-
private <K> List<E> performOrderedMultiLoad(K[] naturalIds, MultiNaturalIdLoadOptions options, SharedSessionContractImplementor session) {
63+
private <K> List<E> performOrderedMultiLoad(K[] naturalIds, MultiNaturalIdLoadOptions options, EventSource eventSource) {
6364
if ( MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
6465
MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER.tracef( "Ordered MultiLoad Starting - `%s`", getEntityDescriptor().getEntityName() );
6566
}
6667

6768
return orderedMultiLoad(
6869
naturalIds,
69-
session,
70+
eventSource,
7071
options.getLockOptions() == null ? LockOptions.NONE : options.getLockOptions()
7172
);
7273
}
7374

74-
protected <K> List<E> orderedMultiLoad( K[] naturalIds, SharedSessionContractImplementor session, LockOptions lockOptions ) {
75+
protected <K> List<E> orderedMultiLoad( K[] naturalIds, EventSource eventSource, LockOptions lockOptions ) {
7576

76-
unorderedMultiLoad( naturalIds, session, lockOptions );
77+
unorderedMultiLoad( naturalIds, eventSource, lockOptions );
7778

78-
return handleResults( naturalIds, session, lockOptions );
79+
return handleResults( naturalIds, eventSource, lockOptions );
7980
}
8081

8182
protected <K> List<E> handleResults( K[] naturalIds, SharedSessionContractImplementor session, LockOptions lockOptions ) {

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiNaturalIdLoaderArrayParam.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import org.hibernate.LockOptions;
1010
import org.hibernate.engine.spi.SessionFactoryImplementor;
11-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
11+
import org.hibernate.event.spi.EventSource;
1212
import org.hibernate.loader.ast.spi.SqlArrayMultiKeyLoader;
1313
import org.hibernate.metamodel.mapping.EntityMappingType;
1414
import org.hibernate.metamodel.mapping.JdbcMapping;
@@ -44,11 +44,11 @@ protected BasicAttributeMapping getNaturalIdAttribute() {
4444
}
4545

4646
@Override
47-
public <K> List<E> unorderedMultiLoad( K[] naturalIds, SharedSessionContractImplementor session, LockOptions lockOptions ) {
47+
public <K> List<E> unorderedMultiLoad(K[] naturalIds, EventSource eventSource, LockOptions lockOptions ) {
4848

49-
final SessionFactoryImplementor sessionFactory = session.getFactory();
49+
final SessionFactoryImplementor sessionFactory = eventSource.getFactory();
5050

51-
naturalIds = LoaderHelper.normalizeKeys( naturalIds, getNaturalIdAttribute(), session, sessionFactory );
51+
naturalIds = LoaderHelper.normalizeKeys( naturalIds, getNaturalIdAttribute(), eventSource, sessionFactory );
5252

5353
final JdbcMapping arrayJdbcMapping = MultiKeyLoadHelper.resolveArrayJdbcMapping(
5454
getNaturalIdMapping().getSingleJdbcMapping(),
@@ -60,7 +60,7 @@ public <K> List<E> unorderedMultiLoad( K[] naturalIds, SharedSessionContractImpl
6060
final SelectStatement sqlAst = LoaderSelectBuilder.createSelectBySingleArrayParameter(
6161
getLoadable(),
6262
getNaturalIdAttribute(),
63-
session.getLoadQueryInfluencers(),
63+
eventSource.getLoadQueryInfluencers(),
6464
lockOptions,
6565
jdbcParameter,
6666
sessionFactory
@@ -86,8 +86,8 @@ public LockOptions getLockOptions() {
8686
null,
8787
null,
8888
lockOptions,
89-
session.isDefaultReadOnly(),
90-
session
89+
eventSource.isDefaultReadOnly(),
90+
eventSource
9191
);
9292
}
9393

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiNaturalIdLoaderInPredicate.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import org.hibernate.LockOptions;
1010
import org.hibernate.engine.spi.SessionFactoryImplementor;
11-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
11+
import org.hibernate.event.spi.EventSource;
1212
import org.hibernate.loader.ast.spi.SqlInPredicateMultiKeyLoader;
1313
import org.hibernate.metamodel.mapping.EntityMappingType;
1414

@@ -22,17 +22,17 @@ public MultiNaturalIdLoaderInPredicate(EntityMappingType entityDescriptor) {
2222
}
2323

2424
@Override
25-
public <K> List<E> unorderedMultiLoad(K[] naturalIds, SharedSessionContractImplementor session, LockOptions lockOptions) {
25+
public <K> List<E> unorderedMultiLoad(K[] naturalIds, EventSource eventSource, LockOptions lockOptions) {
2626

27-
final SessionFactoryImplementor sessionFactory = session.getFactory();
27+
final SessionFactoryImplementor sessionFactory = eventSource.getFactory();
2828

2929
final int maxBatchSize;
3030
if ( options.getBatchSize() != null && options.getBatchSize() > 0 ) {
3131
maxBatchSize = options.getBatchSize();
3232
}
3333
else {
3434
maxBatchSize =
35-
session.getJdbcServices().getJdbcEnvironment().getDialect()
35+
eventSource.getJdbcServices().getJdbcEnvironment().getDialect()
3636
.getMultiKeyLoadSizingStrategy().determineOptimalBatchLoadSize(
3737
getEntityDescriptor().getNaturalIdMapping().getJdbcTypeCount(),
3838
naturalIds.length,
@@ -50,12 +50,12 @@ public <K> List<E> unorderedMultiLoad(K[] naturalIds, SharedSessionContractImple
5050
// `naturalId` here is the one passed in by the API as part of the values array
5151
return getEntityDescriptor().getNaturalIdMapping().normalizeInput( naturalId );
5252
},
53-
session.getLoadQueryInfluencers(),
53+
eventSource.getLoadQueryInfluencers(),
5454
lockOptions,
5555
sessionFactory
5656
);
5757

58-
return batcher.multiLoad( naturalIds, session );
58+
return batcher.multiLoad( naturalIds, eventSource );
5959
}
6060

6161
}

hibernate-core/src/main/java/org/hibernate/loader/ast/spi/MultiNaturalIdLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import java.util.List;
88

9-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
9+
import org.hibernate.event.spi.EventSource;
1010

1111
/**
1212
* Loader for entities by multiple natural-ids
@@ -24,5 +24,5 @@ public interface MultiNaturalIdLoader<E> extends EntityMultiLoader<E> {
2424
* values positioned according to "attribute ordering". Simple natural-ids can also be expressed
2525
* by their simple (basic/embedded) type.
2626
*/
27-
<K> List<E> multiLoad(K[] naturalIds, MultiNaturalIdLoadOptions options, SharedSessionContractImplementor session);
27+
<K> List<E> multiLoad(K[] naturalIds, MultiNaturalIdLoadOptions options, EventSource eventSource);
2828
}

0 commit comments

Comments
 (0)