fix: Filter pra types to get DE and TEA [DHIS2-17243]#17871
fix: Filter pra types to get DE and TEA [DHIS2-17243]#17871enricocolasante merged 3 commits intomasterfrom
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. |
|
david-mackessy
left a comment
There was a problem hiding this comment.
thanks for adding the tests :)



I am asking @dhis2/platform-backend review because I am changing a store method and using
nativeSynchronizedQuery