我有一个以“WITH”子句开头的查询。如果我在具有 DB2 连接的 SQuirrel 中触发相同的查询 - 它可以工作。但是相同的查询在 Hibernate Native SQL 中返回空白数组。
WITH edd_translated_article_tmp (article_id, tran_article_id, tran_article_title,
article_url, source, tran_content )
AS (SELECT M.original_article_id AS article_id,
M.article_id AS TRAN_ARTICLE_ID,
M.article_title AS TRAN_ARTICLE_TITLE,
M.article_url,
M.primary_source AS SOURCE,
M.article_content_html AS TRAN_CONTENT
FROM db2admin.edd_searched_article_main M
WHERE M.original_article_id = 5239415)
SELECT A.article_id,
A.article_title,
A.article_url,
A.primary_source AS SOURCE,
A.article_content_html AS CONTENT,
M.tran_article_id AS TRAN_ARTICLE_ID,
M.tran_article_title AS TRAN_ARTICLE_TITLE,
M.tran_content AS TRAN_CONTENT
FROM db2admin.edd_searched_article_main AS A
LEFT OUTER JOIN edd_translated_article_tmp M
ON A.article_id = m.article_id
WHERE A.article_id = 5239415
休眠本机查询代码:
Query query = getSession().createSQLQuery(sqlNativeQuery);
query.list()