我正在@Formula为我的 Entity/Pojo 类中的一个属性使用注释。在运行时,它正在创建一个查询来获取结果,并且由于 ORA-02000: missing WITHIN keyword无法识别WITHIN为关键字而抛出 ERROR。标记.java@Formula("(SELECT CASE WHEN dis_order IS NULL THEN (SELECT listagg(qpm.displayed_order,', ') WITHIN GROUP (ORDER BY qpm.displayed_order) FROM que_post_mark qpm WHERE qpm.es_id = es_id AND qpm.sez_id = sez_id GROUP BY qpm.es_id, qpm.sez_id) ELSE NULL END FROM dual)")private String childItemsDisplayedOrder;生成的查询如下:select marks0_.*,(SELECT CASE WHEN marks0_.displayed_order IS NULL THEN (SELECT listagg(qpm.displayed_order, ', ') marks0_.WITHIN GROUP (ORDER BY qpm.displayed_order) FROM que_post_mark qpm WHERE qpm.es_id = marks0_.es_id AND qpm.sez_id = marks0_.sez_id GROUP BY qpm.es_id , qpm.sez_id) ELSE NULL END FROM dual) as formula2_0_ from MARKS marks0_ where marks0_.es_id =?它被识别WITHIN为列并附加别名,如marks0_.WITHIN我正在使用以下版本: spring-boot-starter-web = 1.4.0.RELEASE, spring-data-jpa:jar:1.10.2 ,hibernate-entitymanager:jar:5.1.3' hibernate-core:jar:5.1.3, hibernate-jpa-2.1-api:jar我试图降低那些 jar 版本以使其工作,但它没有工作。错误堆栈跟踪如下:Caused by: java.sql.SQLSyntaxErrorException: ORA-02000: missing WITHIN keyword at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399) at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:225) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:53)谁能帮我解决这个问题?
1 回答
30秒到达战场
TA贡献1828条经验 获得超6个赞
我已经通过扩展这个链接中提到的休眠方言类解决了这个问题
public class Oracle10gDialectExtended extends Oracle10gDialect {
public Oracle10gDialectExtended() {
super();
registerKeyword("within"); //Keyword has to be in lowercase.
}
}
使用这个新类设置“hibernate.dialect”属性。
Properties.setProperty("hibernate.dialect", "com.example.Oracle10gDialectExtended");
添加回答
举报
0/150
提交
取消