These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Class where "arbitrary where condition" not issued
PostPosted: Thu Apr 12, 2007 4:44 am 
Newbie

Joined: Wed Feb 28, 2007 11:52 am
Posts: 4
Hi,

I'm having some problem using the where attribute of the class element in complex HQL statements with NHiberante 1.2.0 RC1.

I'm declaring the following mapping :

<class name="Edgar.Logistique.Core.InvenduTypeRejet, Edgar.Logistique.Core" table="YTABLE" where="E0JBCD='00095' and E0EHS1='DTA'">

I need to filter out the "YTABLE" table, because this is legacy data and we can't modifiy the model. This "YTABLE" contains all sort of values, and it's its E0JBCD and E0EHS1 columns that determine the type of value contained. So I want my InvenduTypeRejet class to be bound to the where clause, wherever i'm using it (HQL or Criterias).

When I'm just loading a single instance of InvenduTypeRejet, all is right, the where clause is issued in sql. But when I'm doing some more complex HQL query, the where is not issued anymore.

Check this HQL query :

SELECT new ZoomCadrageInvenduIhmINV322(cadrage.Cle.CodeTitre, cadrage.Cle.CodeEdition, titre.Libelle, cadrage.Cle.NumParution, cadrage.Cle.SuffixeParution, parution.PrixParution, cadrage.Cle.Nil, diffuseur.Nom, cadrage.QuantiteDiffuseur, cadrage.QuantiteMessagerie, typeRejet.LibelleTypeRejet, cadrage.TypeAnomalieMessagerie)

FROM CadrageInvendu as cadrage join cadrage.ParutionLivree as parution
left join cadrage.Diffuseur as diffuseur left join cadrage.VTitre as titre
left join cadrage.InvenduTypeRejet as typeRejet

WHERE cadrage.Cle.NumPermanentDepot = :numPermanentDepot AND cadrage.Cle.CodeReseauDepot = :codeReseauDepot and cadrage.IndicatifCadrage = :indCadrage AND cadrage.Cle.DateClotureInvendu = :dateCloture AND cadrage.Cle.DateBI = :dateBI AND cadrage.Cle.TypeBI = :typeBI and cadrage.QuantiteDiffuseur <> cadrage.QuantiteMessagerie

I think, that because InvenduTypeRejet is in a left join clause, the where condition is not applied to the resulting SQL :

select cadrageinv0_.CDTTPA as x0_0_, cadrageinv0_.CDEDPA as x1_0_, vtitre3_.ACAFTX as x2_0_, cadrageinv0_.NONOPA as x3_0_, cadrageinv0_.CDSFPA as x4_0_, parutionli1_.B2AAPR as x5_0_, cadrageinv0_.CDNLDF as x6_0_, diffuseur2_.A0I6TX as x7_0_, cadrageinv0_.QTCRDF as x8_0_, cadrageinv0_.QTCRMG as x9_0_, invendutyp4_.E0JDNA as x10_0_, cadrageinv0_.TYANMG as x11_0_

from TCDRIV cadrageinv0_
inner join YEDPAR parutionli1_ on cadrageinv0_.CDTTPA=parutionli1_.B2ALCE and cadrageinv0_.NONOPA=parutionli1_.B2AWCD and cadrageinv0_.CDSFPA=parutionli1_.B2AQST
left outer join YEDDIS diffuseur2_ on cadrageinv0_.NOPMDP=diffuseur2_.A0BECD and cadrageinv0_.CDNLDF=diffuseur2_.A0QJCD
left outer join (SELECT YTITRE.*, '1' || ACAHCD as CODTIT FROM YTITRE) vtitre3_ on cadrageinv0_.CDTTPA=vtitre3_.CODTIT
left outer join YTABLE invendutyp4_ on cadrageinv0_.TYANMG=invendutyp4_.E0JCCD

where (cadrageinv0_.NOPMDP=?)AND(cadrageinv0_.CDRSDP=?)and(cadrageinv0_.CDCAIV=?)AND(cadrageinv0_.DTCLIV=?)AND(cadrageinv0_.DTBIDF=?)AND(cadrageinv0_.CDTYBI=?)and(cadrageinv0_.QTCRDF<>cadrageinv0_.QTCRMG)

As the "where" attribute of element class is not really documented, I don't know what is the desgnied behaviour. What do you think of this ? Is this a bug ? If not, what should I use instead of the "where" atribute to filter out my "YTABLE" table ? Discriminator ? Is it possible with more than one column ?

Thanks !

Christophe


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.