From: Matan (JIRA) <no...@at...> - 2006-06-19 12:10:32
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1397?pa= ge=3Dcomments#action_23356 ]=20 Matan commented on HHH-1397: ---------------------------- My workaround is direct SQL (yuck!).... only thing that avoids the performa= nce bottleneck. Surprised we aren't getting any feedback from the team though... > HQL insert into ... select ... statement problem due to lacking table ali= ases in select clause > -------------------------------------------------------------------------= --------------------- > > Key: HHH-1397 > URL: http://opensource.atlassian.com/projects/hibernate/browse/H= HH-1397 > Project: Hibernate3 > Type: Bug > Components: query-hql > Versions: 3.1.1 > Environment: 3.1.1., PostgresSQL > Reporter: Lukas Barton > > > I have got problem with INSERT INTO ... SELECT ... > As I have very complex table stucture and join many tables easy workaroun= d is not possible :-( > I have SQL like this: > insert into IdfKlient (dotazID,tabulkaVSabloneID,obec,status,metaTypKlien= ta,ulice,ic,psc,rc,jmeno,idKlient) select dotaz.id,sablonaMain.id,dtaklient= .obec,dtaklient.status,dtaklient.metaTypKlienta,dtaklient.ulice,dtaklient.i= c,dtaklient.psc,dtaklient.rc,dtaklient.jmeno,dtaklient.idKlient from DtaKli= ent as dtaklient,Dotaz as dotaz,TabulkaVSablone as sablonaMain, HodnotaPara= metruDotazuString parametr_0 where sablonaMain.id=3D:sablona_id and exists(= from Sablona as sablona where dotaz.sablona=3Dsablona and sablona.hlavniTab= ulka=3DsablonaMain and exists(from IdfDavka as davka where dotaz.davka=3Dda= vka and davka.status=3D:status)) and parametr_0.dotaz=3Ddotaz and dtaklient= .rc=3Dparametr_0.hodnota and exists (from Parametr as param where param=3Dp= arametr_0.parametr) > But hibernate translates it into this (see where at the and of statement = - where idsablona=3Did and hlavnitabulka=3Didtabulkavsablone......): > insert into idfklient ( dotaz_id, sablona_id, obec, status, metatypklient= a_id, ulice, ic, psc, rc, jmeno, idklient ) select dotaz1_.id as col_0_0_, = tabulkavsa2_.idtabulkavsablone as col_1_0_, dtaklient0_.obec as col_2_0_, d= taklient0_.status as col_3_0_, dtaklient0_.metatypklienta_id as col_4_0_, d= taklient0_.ulice as col_5_0_, dtaklient0_.ic as col_6_0_, dtaklient0_.psc a= s col_7_0_, dtaklient0_.rc as col_8_0_, dtaklient0_.jmeno as col_9_0_, dtak= lient0_.idklient as col_10_0_ from dtaklient dtaklient0_, dotaz dotaz1_, ta= bulkavsablone tabulkavsa2_, hodnotaparametrudotazustring hodnotapar3_ inner= join hodnotaparametrudotazu hodnotapar3_1_ on hodnotapar3_.idhodnoty=3Dhod= notapar3_1_.id where idtabulkavsablone=3D? and (exists (select sablona4_.id= from sablona sablona4_ where idsablona=3Did and hlavnitabulka=3Didtabulkav= sablone and (exists (select idfdavka5_.ID from IDFDAVKA idfdavka5_ where id= davky=3DID and STATUS=3D?)))) and iddotazu=3Did and rc=3Dhodnota and (exist= s (select parametr6_.id from parametr parametr6_ where id=3Didparametru)) > I found similar error here: http://opensource2.atlassian.com/projects/hib= ernate/browse/HHH-1349 --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators= .jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |