我需要在FK中的表中插入大量数据,另一个在Eager中有两个大字段。
HQL查询是:
insert into DeviceAuthorizationEntry (id, osc, moduleName, delegateModule, functionName, groupName, owner)
select concat(item0.id.uuid, '1413971469473'), item0.osc, 'aaaaaaaa',
'devices', 'view_devices', 'administrator', item0
from device.model.Device as item0
where item0.osc IN (:oscNameList0)
and item0.nodeTypeDefinition.QN IN (:nodeTypesList0)
and not exists (select 1 from device.model.DeviceAuthorizationEntry as auth
where auth.moduleName != 'aaaaaaa'
and auth.delegateModule != 'devices'
and auth.functionName != 'view_devices'
and auth.groupName != 'administrator'
and auth.owner != item0 )
但是在Oracle上执行的是:
INSERT
INTO DeviceAuthorizationEntry
(
id,
osc,
moduleName,
delegateModule,
functionName,
groupName,
owner_uuid
)
SELECT device0_.uuid
||'1413965664136' AS col_0_0_,
device0_.osc AS col_1_0_,
'aaaaaaaa' AS col_2_0_,
'devices' AS col_3_0_,
'view_devices' AS col_4_0_,
'administrator' AS col_5_0_,
device0_.uuid AS col_6_0_
FROM dem_device device0_,
cor_noddef nodetypede1_
WHERE device0_.uuid_ndtypedef=nodetypede1_.uuid
AND 1 =1
AND (device0_.osc IN (? , ?))
AND (nodetypede1_.QN IN (? , ? , ? , ? , ? , ? , ? , ? , ?))
AND NOT (EXISTS
(SELECT 1
FROM DeviceAuthorizationEntry deviceauth2_
WHERE deviceauth2_.moduleName <>'aaaaaaaa'
AND deviceauth2_.delegateModule<>'devices'
AND deviceauth2_.functionName <>'view_devices'
AND deviceauth2_.groupName <>'administrator'
AND deviceauth2_.owner_uuid <>uuid
))
正如你在上一个&#34;和&#34;对于存在子查询,hibernate不在&#34; uuid&#34;之前。带别名的字段&#34; device0 _&#34;。
Hibernate支持插入到select中,如您在此处https://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html/ch11.html#d5e2610
所示我不知道我错在哪里。