我正在使用EclipseLink连接不同的数据库。并针对DB2和SQLServer运行相同的查询。查询在DB2上运行良好但在SQLServer上运行失败。
以下是错误消息:
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: 'ROWNUMBER'
is not a recognized built-in function name.
Error Code: 195
Call: SELECT * FROM (SELECT * FROM (SELECT EL_TEMP.*, ROWNUMBER() OVER() AS EL_R
OWNM FROM (SELECT t0.EVAL_ID AS a1, t0.EVAL_TYP_ID AS a2, t0.CREATE_DATETM AS a3
, t0.EVAL_DESC AS a4, t0.EVAL_NAME AS a5, t0.REVISION_NBR AS a6, t0.UPDATE_DATET
M AS a7, t1.LOGICL_DB AS a8, t1.QUERY_STRING_HASH AS a9, t1.QUERY_STRING_TXT AS
a10 FROM EVAL t0, SQL_EVAL t1 WHERE ((t0.EVAL_NAME = ?) AND ((t1.EVAL_ID = t0.EV
AL_ID) AND (t0.EVAL_TYP_ID = ?))) ORDER BY t0.REVISION_NBR DESC) AS EL_TEMP) AS
EL_TEMP2 WHERE EL_ROWNM <= ?) AS EL_TEMP3 WHERE EL_ROWNM > ?
bind => [BA-TD.LODG_RM_NIGHT_TRANS_FACT.PRICE_AMT_LOCAL_WITH_OMS, 1, 1,
0]
我认为这个查询是由EclipseLink生成的,因为我的原始查询非常简单。我的问题是,SQLServer无法识别&#39; ROWNUMBER&#39;所以如何将其更改为&#39; ROW_NUMBER&#39;?有没有办法配置EclipseLink如何生成SQL?
谢谢!
答案 0 :(得分:1)
尝试将 eclipselink.target-database 属性设置为 org.eclipse.persistence.platform.database.SQLServerPlatform :
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.SQLServerPlatform"/>