-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Panache Hibernate: generates wrong sql when using CAST #44405
Comments
/cc @FroMage (panache), @gsmet (hibernate-orm), @loicmathieu (panache), @yrodiere (hibernate-orm) |
This might be fixed by #41620 for Quarkus 3.17 |
I don't see a runnable reproducer here, so hard to tell :/ @nimo23 Can you please check your application against Quarkus 3.17? The latest snapshots for sure include the patch. See https://github.com/quarkusio/quarkus/blob/main/CONTRIBUTING.md#checking-an-issue-is-fixed-in-main for instructions on how to use the latest snapshots of Quarkus in your application. |
I tried it today with
You can try it yourself. Simply use a query like the following where you cast a
The following version, using
|
https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#pc-filter specifically states:
And
But… also, the /**
* <p>
* Enables a Hibernate filter during fetching of results for this query. Your filter must be declared
* with {@link FilterDef} on your entity or package, and enabled with {@link Filter} on your entity.
* <p>
* WARNING: setting filters can only be done on the underlying Hibernate {@link Session} and so this
* will modify the session's filters for the duration of obtaining the results (not while building
* the query). Enabled filters will be removed from the session afterwards, but no effort is made to
* preserve filters enabled on the session outside of this API.
*
* @param filterName The name of the filter to enable
* @return this query, modified
*/
public <T extends Entity> PanacheQuery<T> filter(String filterName); So, I'm not sure what |
Ok, I didn't know that. So the following syntax is correct:
I was calling the following method:
Normally when using Hibernate you think you can use |
Describe the bug
I use the following Panache filter query:
The JPQL fragment appears to be correct as it works when using this query in the Hibernate console. However, it seems that Panache JPA (or Hibernate?) converts this JPQL into the following SQL query, which then throws the following exception:
Hibernate or Panache JPA wrongly converts the
String
-datatype tot1_0.String
but String does not correspond to a field in the schema t1_0, it is simply a datatype needed for conversion.When I use this JPQL no error is thrown and the generated SQL is correct.
Expected behavior
No exception should be thrown for valid JQPL.
Actual behavior
Exception is thrown for valid JQPL.
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
openjdk version "21.0.2" 2024-01-16
Quarkus version or git rev
3.16.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: