Skip to content

Commit 82c18c0

Browse files
committed
DATAJPA-920 - Polishing.
Formatting and a bit of JavaDoc polish in JpaQueryCreator. Original pull request: #176.
1 parent 84314e2 commit 82c18c0

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;
@@ -63,10 +62,10 @@ public class JpaQueryCreator extends AbstractQueryCreator<CriteriaQuery<? extend
6362
/**
6463
* Create a new {@link JpaQueryCreator}.
6564
*
66-
* @param tree
67-
* @param domainClass
68-
* @param accessor
69-
* @param em
65+
* @param tree must not be {@literal null}.
66+
* @param type must not be {@literal null}.
67+
* @param builder must not be {@literal null}.
68+
* @param provider must not be {@literal null}.
7069
*/
7170
public JpaQueryCreator(PartTree tree, ReturnedType type, CriteriaBuilder builder,
7271
ParameterMetadataProvider provider) {
@@ -94,7 +93,8 @@ protected CriteriaQuery<? extends Object> createCriteriaQuery(CriteriaBuilder bu
9493

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

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

100100
/**
@@ -169,24 +169,26 @@ protected CriteriaQuery<? extends Object> complete(Predicate predicate, Sort sor
169169
}
170170

171171
query = query.multiselect(selections);
172+
172173
} else if (tree.isExistsProjection()) {
173174

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

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

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

182-
Set<SingularAttribute<?, ?>> idClassAttributes = (Set<SingularAttribute<?, ?>>) root.getModel().getIdClassAttributes();
183-
184-
for (SingularAttribute<?, ?> attribute : idClassAttributes) {
184+
for (SingularAttribute<?, ?> attribute : root.getModel().getIdClassAttributes()) {
185185
selections.add(root.get((SingularAttribute) attribute).alias(attribute.getName()));
186186
}
187+
187188
selections.add(root.get((SingularAttribute) id).alias(id.getName()));
188189
query = query.multiselect(selections);
189190
}
191+
190192
} else {
191193
query = query.select((Root) root);
192194
}

0 commit comments

Comments
 (0)