title: HQL generate wrong query with complex insert
body: <p>I need to insert a huge amount of data in a table that is in FK with another one that has a two big fields in Eager.</p>
  
  <p>The HQL query is:</p>
  
  <pre><code>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 )
  </code></pre>
  
  <p>But the one executed on Oracle is:</p>
  
  <pre><code>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  &lt;&gt;'aaaaaaaa'
    AND deviceauth2_.delegateModule&lt;&gt;'devices'
    AND deviceauth2_.functionName  &lt;&gt;'view_devices'
    AND deviceauth2_.groupName     &lt;&gt;'administrator'
    AND deviceauth2_.owner_uuid    &lt;&gt;uuid
    ))
  </code></pre>
  
  <p>As you can see in the last "and" of the exists subquery, hibernate does not precede the "uuid" field with the alias "device0_".</p>
  
  <p>Hibernate supports the insert into select as you can see here <a href="https://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html/ch11.html#d5e2610" rel="nofollow">https://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html/ch11.html#d5e2610</a></p>
  
  <p>I don't know where I'm wrong.</p>