JPQL query verification at startup

I had an idea but I’m unsure of the implementation.

I’ve noticed that I frequently make syntax errors in my JPQL queries (forgetting to name a join, misspelled attribute, etc.). But I don’t usually find these errors until I try to open a screen.

My thought is that it would be incredibly useful to do a check as part of the startup process that runs through each screen and attempts to compile the JPQL into SQL without executing the SQL.

Granted, this would not catch inconsistencies between the data model and the database, but it would catch the syntax errors. The Studio is very good at checking for those data model inconsistencies anyway.

To the question at hand, how can I find a list of all screen controllers? If I can get that list, I can iterate through and check each loader and attempt to parse the query at start up using an application event listener.

Hi,

From your description I would assume that most like what you want to achieve is to gain confidence in what you developed. Since JPQL errors are not caught by the compiler, the next natural thing to gain that confidence is test automation. You can run these checks before you deploy the code, so it is earlier in the dev lifecycle…

In case of CUBA you can use the web integration tests / selenium based tests to achieve this. In case of Jmix, you can even run web integration tests to fetch data programmatically.

Cheers
Mario

Hi,
I would recommend to purchase IDEA Ultimate subscription and setup JPA facets for your CUBA projects. IDEA Ultimate has built-in support for the JPQL language, and CUBA plugin integrates with this support. You will be able to use code completion and query highlighting in JPQL queries.
Here are few screenshots:
https://doc.cuba-platform.com/studio/#_feature_examples