Open sdlzhd opened 4 months ago
/cc @FroMage (panache), @loicmathieu (panache)
Hi,
Thanks for reporting. This is due to you calling a count()
method on a query where one of the parameter is only used in the order by
clause, which is not used by the count
query (ordering is not useful for counting). That's rather unfortunate.
I'm not sure yet how to fix this.
As a workaround, you can drop the location
parameter when using count
.
I could use the HQL parser to verify which parameters to not bind from the count query, but that's going to make it more expensive for everyone.
I could try using the new API for counting results in ORM :)
It appears to. Good news, this makes it upstream's problem next time it happens. But it breaks projections, I have to look at that.
Thank you for your work. I am using paging query and I do not want to open a query to count.
PanacheQuery<Store> page = find(query, params).page(Page.of(0, 10));
long count = page.count();
List<Store> list = page.list();
I've reported https://hibernate.atlassian.net/browse/HHH-18234
Thank you for your work. I am using paging query and I do not want to open a query to count.
I understand, but in any case there will always be two queries, as the count query is executed separately, even if you don't see it. So as a workaround, to get you unstuck until we have a fix, you can create a separate query for counting.
There's a fix for that in ORM 6.5.3. I'll make a PR to fix this when we upgrade to that version.
Describe the bug
I'm using Panache to simplify Hibernate queries. When I use the following query, I get an exception:
find("name = :name ORDER BY ST_Distance(location, :location) DESC", Map.of("name", "Demo","location", point))
But, If I create the query directly using Hibernate, everything is fine.
Expected behavior
Set the parameters correctly
Actual behavior
UnknownParameterException: No parameter named ':location' in query with named parameters []
How to Reproduce?
In the description part gives a simple query, only need to create a table, containing the Point/geom type field;
Regardless of the database, the behavior is the same in MySQL and Postgresql
Output of
uname -a
orver
Linux 5.15.146.1-microsoft-standard-WSL2 Ubuntu
Output of
java -version
OpenJDK Runtime Environment Temurin-21.0.3+9
Quarkus version or git rev
3.11.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)maven 3.9.7
Additional information
The sort is not part of the query