ruthst00 commented on code in PR #16573:
URL: https://github.com/apache/grails-core/pull/16573#discussion_r4415134297
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaCriteriaQueryCreator.java:
##########
@@ -308,49 +284,14 @@ private void assignOrderBy(CriteriaQuery<?> cq,
JpaQueryContext context) {
private boolean isCountOnly() {
List<Query.Projection> projectionList =
projections.getProjectionList();
return !projectionList.isEmpty() && projectionList.stream()
- .allMatch(projection -> projection instanceof
Query.CountProjection ||
- projection instanceof Query.CountDistinctProjection);
- }
-
- private void discoverAliases(List<Query.Criterion> criteria,
JpaQueryContext context) {
- if (criteria == null) return;
- for (Query.Criterion criterion : criteria) {
- if (criterion instanceof HibernateAlias ha) {
- // If the alias is already defined in parent and materialized,
just link it
- if (!context.hasAlias(ha.alias())) {
- context.registerAlias(ha.alias(), ha);
- }
- } else if (criterion instanceof DetachedAssociationCriteria<?>
dac) {
- if (dac.getAlias() != null) {
- context.registerAlias(dac.getAlias(), new
HibernateAlias(dac.getAssociationPath(), dac.getAlias()));
- }
- discoverAliases(dac.getCriteria(), context);
- } else if (criterion instanceof Query.PropertyNameCriterion pnc) {
- String propertyName = pnc.getProperty();
- if (propertyName.contains(".")) {
- String alias = propertyName.substring(0,
propertyName.indexOf("."));
- // Only register if not already known in this or parent
context
- if (!context.hasAlias(alias)) {
- context.registerAlias(alias, new HibernateAlias(alias,
alias));
- }
- }
- } else if (criterion instanceof Query.Junction junction) {
- discoverAliases(junction.getCriteria(), context);
- }
- }
- }
-
- private void registerDetachedJoins(JpaQueryContext context) {
- detachedCriteria.getJoinTypes().forEach((path, joinType) ->
- context.registerAlias(path, new HibernateAlias(path, path,
joinType))
- );
+ .allMatch(projection -> projection instanceof
Query.CountProjection || projection instanceof Query.CountDistinctProjection);
Review Comment:
Fixed in
https://github.com/apache/grails-core/pull/16573/changes/ece3fd3d52a7b914a0cbf598d476e8b877312ac4
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]