EclipseLink has a column() function, which is very similar in nature to the function() function which is already in JPQL. [That's because function() came directly from TopLink.] I think it would be nice to add that to JPQL.
EclipseLink and Hibernate also both have a sql() function, allowing arbitrary fragments of SQL, with almost identical syntax. [Because Hibernate copied EclipseLink, I believe.] We could consider including this one too.
The only wrinkle is that I would like to make two improvements:
drop the requirement that column/function names be quoted, at least in the overwhelmingly common case that they are legal JPQL identifiers, and
add a way to specify the type of the column or function.
So I would allow:
column(a.column_name as String)
function(funname as Double, a.x, b.y)
If we wanted to also allow sql, the full syntax would be something like:
sql('(? <-> ?)' as Boolean, a.x, b.y)
but I think this one is a bit more complex and more difficult to specify. I'm not sure it's worth adding.
EclipseLink has a
column()
function, which is very similar in nature to thefunction()
function which is already in JPQL. [That's becausefunction()
came directly from TopLink.] I think it would be nice to add that to JPQL.EclipseLink and Hibernate also both have a
sql()
function, allowing arbitrary fragments of SQL, with almost identical syntax. [Because Hibernate copied EclipseLink, I believe.] We could consider including this one too.The only wrinkle is that I would like to make two improvements:
So I would allow:
column(a.column_name as String)
function(funname as Double, a.x, b.y)
If we wanted to also allow
sql
, the full syntax would be something like:sql('(? <-> ?)' as Boolean, a.x, b.y)
but I think this one is a bit more complex and more difficult to specify. I'm not sure it's worth adding.