Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 不在Eclipselink中工作的函数和运算符_Java_Jakarta Ee_Jpa_Eclipselink - Fatal编程技术网

Java 不在Eclipselink中工作的函数和运算符

Java 不在Eclipselink中工作的函数和运算符,java,jakarta-ee,jpa,eclipselink,Java,Jakarta Ee,Jpa,Eclipselink,我有这个问题,REPLACE函数在eclipselink 2.5.2版中不起作用 这是我的密码: String sSql = " SELECT e FROM br.com.megasoft.protocolo.entity.Assunto e WHERE ( REPLACE(REPLACE(REPLACE( UPPER(e.titulo), '/', ''), '-', ''), '.', '') LIKE UPPER('A') )"; TypedQuery<?> query

我有这个问题,REPLACE函数在eclipselink 2.5.2版中不起作用

这是我的密码:

String sSql = " SELECT e FROM br.com.megasoft.protocolo.entity.Assunto e  WHERE  ( REPLACE(REPLACE(REPLACE( UPPER(e.titulo), '/', ''), '-', ''), '.', '') LIKE  UPPER('A') )";
TypedQuery<?> query = getEntityManager().createQuery(sSql, Class.forName(this.tabela));
当我使用Hibernate时,它可以完全正常工作

当我运行简单的SQL时,没有替换,它工作得很好


Obs:Eclipselink 2.5.2正在使用JPA2.1。我使用的是Tomcat8,EclipseKepler。

我在规范和oracle页面()中搜索过,没有替换JPQL函数

我相信这是一个休眠函数:

换句话说,REPLACE属于HQL而不是JPQL。

JPA2.1具有JPQL“函数”,允许在JPQL语句中使用SQL函数。
您使用的不是JPQL作为规范的简单回顾,或者您的JPA实现的文档会告诉您

我找到了解决方案,感谢大家提供有用的信息

sql应该是这样的:

SELECT e FROM br.com.megasoft.protocolo.entity.Assunto e  WHERE  FUNCTION('REPLACE',  e.titulo, '/', '') LIKE  UPPER('A')

这样,我将使用JPA 2.1规范中定义的函数

谢谢你提供的信息@Billy,你能帮我建立这个查询吗?我试过这样做:从br.com.megasoft.protocolo.entity.ass中选择e,直到e WHERE FUNCTION('REPLACE',e.campo',/','')=UPPER('A')仍然不工作。什么是“不工作”?日志告诉您调用了什么SQL,因此您可以从该日志返回以定义查询。
SELECT e FROM br.com.megasoft.protocolo.entity.Assunto e  WHERE  FUNCTION('REPLACE',  e.titulo, '/', '') LIKE  UPPER('A')