Skip to content

Commit 5604630

Browse files
DavideDSanne
authored andcommitted
Clean up ReactiveSingleUniqueKeyEntityLoaderStandard
1 parent bfcdc64 commit 5604630

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect;
3939
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
4040

41+
import static java.util.Collections.emptyList;
42+
4143
/**
4244
*
4345
* @param <T>
@@ -51,12 +53,13 @@ public ReactiveSingleUniqueKeyEntityLoaderStandard(
5153
EntityMappingType entityDescriptor,
5254
SingularAttributeMapping uniqueKeyAttribute) {
5355
this.entityDescriptor = entityDescriptor;
54-
if ( uniqueKeyAttribute instanceof ToOneAttributeMapping ) {
55-
this.uniqueKeyAttribute = ( (ToOneAttributeMapping) uniqueKeyAttribute ).getForeignKeyDescriptor();
56-
}
57-
else {
58-
this.uniqueKeyAttribute = uniqueKeyAttribute;
59-
}
56+
this.uniqueKeyAttribute = uniqueKeyAttribute instanceof ToOneAttributeMapping
57+
? ( (ToOneAttributeMapping) uniqueKeyAttribute ).getForeignKeyDescriptor()
58+
: uniqueKeyAttribute;
59+
}
60+
61+
private static Object transformRow(Object[] row) {
62+
return row[0];
6063
}
6164

6265
@Override
@@ -72,7 +75,7 @@ public CompletionStage<T> load(Object ukValue, LockOptions lockOptions, Boolean
7275
final List<JdbcParameter> jdbcParameters = new ArrayList<>();
7376
final SelectStatement sqlAst = LoaderSelectBuilder.createSelectByUniqueKey(
7477
entityDescriptor,
75-
Collections.emptyList(),
78+
emptyList(),
7679
uniqueKeyAttribute,
7780
null,
7881
1,
@@ -103,7 +106,7 @@ public CompletionStage<T> load(Object ukValue, LockOptions lockOptions, Boolean
103106
jdbcSelect,
104107
jdbcParameterBindings,
105108
new SingleUKEntityLoaderExecutionContext( session, readOnly ),
106-
row -> row[0],
109+
ReactiveSingleUniqueKeyEntityLoaderStandard::transformRow,
107110
ReactiveListResultsConsumer.UniqueSemantic.FILTER
108111
)
109112
.thenApply( list -> singleResult( ukValue, list ) );

0 commit comments

Comments
 (0)