-
Notifications
You must be signed in to change notification settings - Fork 363
fix: Filter pra types to get DE and TEA [DHIS2-17243] #17871
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
Conversation
Hi @enricocolasante, one of the concerns about using the native query, and it's mentioned in the javadoc, is that it should only target the same table of the store, in this case |
Changed to use |
bcde7f0
to
9f90439
Compare
This still hits the native query force cache issue, and is probably worse now. Is there a specific reason to use a native query? return getQuery(sql, String.class)
.setParameter("types", serverSupportedTypes)
.getResultList(); Using that method does not hit the Hibernate cache issue as Hibernate is fully aware of the objects involved in the query. So no flush is triggered. |
Also, any fix should usually be accompanied with a test, proving the absence of the bug being fixed. |
FYI: If you look at the implementation of As David pointed out, if you use HQL that part is done for you. But there are other reasons to prefer SQL over HQL so I also think it is wrong to advocate for HQL purely because hibernate is asking you to do this manually. One could even get the idea they did that on purpose to make users dependent. Because they could have easily offered an option to run the SQL on the same basis as the HQL. It is not that this would be hard to figure out based on the hibernate mappings. |
Thanks for the comments, it was a quite confusing PR as it is extracted from a bigger one just to try to make it smaller but it was very clarifying for me. I thought I was confused about the different query option that we have but I found out that I was more than expected. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding the tests :)
I am asking @dhis2/platform-backend review because I am changing a store method and using
nativeSynchronizedQuery