问题
I'm using EclipseLink. Is is possible to use custom query function like:
Select u from User u where my_function(u.name) = my_function(:param)
I would like to retrive entities based on custom created slug names rather than id (and remove any id's from url)
回答1:
If you implement it as function in database then it is possible, otherwise not (because it translates to SQL in the end anyway calls to method implemented with Java are not possible). Keyword func is used to call database function:
Select u from User u
where func('my_function', u.name) = func('my_function', :param)
来源:https://stackoverflow.com/questions/9341668/create-custom-jpa-query-function