Create custom JPA query function

妖精的绣舞 提交于 2020-01-06 05:46:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!