But that will obviously not check at compile time if the age attribute is assignable to Integer. The checks for entity views are at application boot time, though they are more thorough, i.e. assignability is checked.
You can also write queries with the JPA Criteria API or QueryDSL if you would like to exchange a little readability for type-safety.
Thanks a lot! Is the (partial) compile time check with Hibernate JPA metamodel generator also working with implicit or explicit JOIN statements, subqueries etc.? I.e. can a BP query always be rewritten so that there is this kind of check at compile time.
Since Hibernate ORM and JPA don’t support implicit joins over collections, that’s not going to work unfortunately. You would have to reformulate your query to use explicit joins then.
This example will work as it is, but you asked about whether this BP query could be rewritten to JPA Criteria to achieve compile time checks:
And the answer is yes, but you would need to use an explicit join in the select clause i.e. instead of kittens.age you will have to refer to kitty.age directly, because JPA Criteria and Hibernate ORM don’t support implicit joins over collections.
For the sake of example, this could be written as:
Actually, I have not formulated my question well :
the question was : can i rewrite in Blaze-Persistence the query with JOINs (and yes, the query is already written in Blaze Persistence) butwith compile time checks, so using the Hibernate JPA metamodel. So rewrite the same query, in Blaze-Persistence, but with compile-time checks (that remain partial, as I understood from your first reply).
And the fact BP supports implicit JOIN over collections is good news.
But note that you don’t have to fully give up on type safety. Blaze-Persistence has a QueryDSL frontend as well as a JPA Criteria API frontend as well, which both produce the Blaze-Persistence CriteriaBuilder in the end. So you can still combine that with entity views or write most of your query with one API and switch to the Blaze-Persistence CriteriaBuilder API when needed.