FROM Student st
(:name IS NULL OR LOWER (st.name) LIKE LOWER (:name%))
AND (:surname IS NULL OR LOWER (st.surname) LIKE LOWER (:surname%))
AND (:age IS NULL OR st.age = :age)
AND (:hairColour IS NULL OR st.hairCoulour = :hairColour)
Jayesh A Lalwani wrote:Why aren;t you using the Criteria API? Seems like a perfect fit for what you need to do.
James Sutherland wrote:Some JPA providers such as EclipseLink maintain a JPQL parse cache. So if you execute the same dynamic query multiple times, it will not need to re-parse the query.
As long as you use parameters in your query, even with dynamic arguments, the number of probably JPQL strings will be a small set, and be cached.