Skip to content

QueryUtils.createCountQueryFor does not work for all sub queries #2166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Artur- opened this issue Mar 2, 2021 · 3 comments
Closed

QueryUtils.createCountQueryFor does not work for all sub queries #2166

Artur- opened this issue Mar 2, 2021 · 3 comments
Labels
status: duplicate A duplicate of another issue

Comments

@Artur-
Copy link

Artur- commented Mar 2, 2021

Given for instance

"SELECT NEW abc.ProductWithSales(product.name, product.price, product.category, (SELECT SUM(row.sum) FROM SaleRow row WHERE row.product = product.id)) FROM Product as product"

produces

select count(row) FROM SaleRow row WHERE row.product = product.id)) FROM Product as product

which is nonsense

@Artur-
Copy link
Author

Artur- commented Mar 2, 2021

A working count query for this case would be

"SELECT COUNT (product) FROM Product as product"

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 2, 2021
@Artur-
Copy link
Author

Artur- commented Mar 3, 2021

Another query would be the one mentioned in Hibernate docs for sub queries:

select cat.id, (select max(kit.weight) from cat.kitten kit)
from Cat as cat

This is is handled incorrectly as well:

select count(kit) from cat.kitten kit) from Cat as cat

@schauder
Copy link
Contributor

schauder commented Mar 3, 2021

The original scenario is a duplicate of #1895 I also consider the scenario mentioned in the previous comment the same issue.

@schauder schauder closed this as completed Mar 3, 2021
@schauder schauder added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants