出于性能原因,我试图用JOIN替换一个巨大的IN子句(数百个值),因此我创建了一个全局临时表(Oracle),希望它可能是可行的选择:
CREATE GLOBAL TEMPORARY TABLE TMP_USER_GUID (
user_guid varchar(20)
)
ON COMMIT DELETE ROWS
当我手动运行sql时,它运行良好:
INSERT ALL
INTO ent.tmp_usr_guid VALUES ('00JD49W7IJ93ZU5MBWBQ')
-- as many INTO statements as I would have IN parameters
SELECT * FROM DUAL;
SELECT u.guid, u.first_name, u.last_name, ...
FROM usr u
JOIN ...
JOIN ...
JOIN tmp_usr_guid tug ON u.guid = tug.usr_guid
当我尝试使用Hibernate(5.2.12.FINAL)作为本机sql语句运行它时,它会抛出:
org.hibernate.QueryException:意外的char:';' [将所有内容插入 ent.tmp_usr_guid VALUES('00JD49W7IJ93ZU5MBWBQ')SELECT * FROM DUAL; 选择u.guid,
对采取正确方法有任何想法吗?