Skip to content

Commit 96c1251

Browse files
committed
DATAJPA-920 - Polishing.
Formatting and a bit of JavaDoc polish in JpaQueryCreator. Original pull request: #176.
1 parent e07e53e commit 96c1251

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.Collection;
2424
import java.util.Iterator;
2525
import java.util.List;
26-
import java.util.Set;
2726

2827
import javax.persistence.criteria.CriteriaBuilder;
2928
import javax.persistence.criteria.CriteriaQuery;
@@ -62,10 +61,10 @@ public class JpaQueryCreator extends AbstractQueryCreator<CriteriaQuery<? extend
6261
/**
6362
* Create a new {@link JpaQueryCreator}.
6463
*
65-
* @param tree
66-
* @param domainClass
67-
* @param accessor
68-
* @param em
64+
* @param tree must not be {@literal null}.
65+
* @param type must not be {@literal null}.
66+
* @param builder must not be {@literal null}.
67+
* @param provider must not be {@literal null}.
6968
*/
7069
public JpaQueryCreator(PartTree tree, ReturnedType type, CriteriaBuilder builder,
7170
ParameterMetadataProvider provider) {
@@ -93,7 +92,8 @@ protected CriteriaQuery<? extends Object> createCriteriaQuery(CriteriaBuilder bu
9392

9493
Class<?> typeToRead = type.getTypeToRead();
9594

96-
return (typeToRead == null || tree.isExistsProjection()) ? builder.createTupleQuery() : builder.createQuery(typeToRead);
95+
return typeToRead == null || tree.isExistsProjection() ? builder.createTupleQuery()
96+
: builder.createQuery(typeToRead);
9797
}
9898

9999
/**
@@ -168,24 +168,26 @@ protected CriteriaQuery<? extends Object> complete(Predicate predicate, Sort sor
168168
}
169169

170170
query = query.multiselect(selections);
171+
171172
} else if (tree.isExistsProjection()) {
172173

173174
if (root.getModel().hasSingleIdAttribute()) {
174175

175176
SingularAttribute<?, ?> id = root.getModel().getId(root.getModel().getIdType().getJavaType());
176177
query = query.multiselect(root.get((SingularAttribute) id).alias(id.getName()));
178+
177179
} else {
178180

179181
List<Selection<?>> selections = new ArrayList<Selection<?>>();
180182

181-
Set<SingularAttribute<?, ?>> idClassAttributes = (Set<SingularAttribute<?, ?>>) root.getModel().getIdClassAttributes();
182-
183-
for (SingularAttribute<?, ?> attribute : idClassAttributes) {
183+
for (SingularAttribute<?, ?> attribute : root.getModel().getIdClassAttributes()) {
184184
selections.add(root.get((SingularAttribute) attribute).alias(attribute.getName()));
185185
}
186+
186187
selections.add(root.get((SingularAttribute) id).alias(id.getName()));
187188
query = query.multiselect(selections);
188189
}
190+
189191
} else {
190192
query = query.select((Root) root);
191193
}

0 commit comments

Comments
 (0)