I personally believe that the latter is correct because the intention of using CriteriaBuilder.literal() is for an actual literal to make it into the generated SQL string. Because if users wanted a parameter, they could have used CriteriaBuilder.parameter() instead. What's the point of literal() if it still generates a parameter.
Nothing says that a literal in HQL or JPQL or Criteria needs to be a literal in SQL. You are simply making an assumption - which is fine. But an assumption or interpretation != what the spec says. Using a parameter at the SQL level is better and we will continue to do that if/when we can. That said, as I mentioned on
HHH-9576 Open I already have code in place to allow users to configure this behavior. To me that is the ideal solution. |