Nhibernate, Left join, with clause
Bonjour tout le monde,
je suis actuellement sur un problème de requête sous Nhibernate
(ma version de dll date de début aout... plutot récent)
La requête de base est lente, et travaillant la requête sous commande SQL, j'arrive à l'optimiser
problème, je n'arrive pas à transposer cette optimisation en C# avec nhibernate
comment ça se passe :
Exemple de mon modèle
TABLE_A { A_Identifiant, A_Libelle, A_Relation_B_ident}
TABLE_B { B_Identifiant, B_Libelle}
Actuellement, lorsque les requêtes sont créées, elles sont mises en place de la manière suivante
Code:
1 2
| Select A_Libelle, B_Libelle from TABLE_A
left join TABLE_B; |
nhibernate passe par là en interprétant les xml du modele, en considérant le champ A_Relation_B_ident comme une entité et non comme un champ et on obtient :
Code:
1 2
| Select A_Libelle, B_Libelle from TABLE_A
left outer join TABLE_B on TABLE_A.A_Relation_B_ident = TABLE_B.B_Identifiant; |
problème, c'est qu'avec ce genre de truc, on a des full access sur les tables
une des optimisations, consistes à ajouter un truc tout simple
Code:
1 2 3 4
| Select A_Libelle, B_Libelle from TABLE_A
left outer join TABLE_B
on TABLE_A.A_Relation_B_ident = TABLE_B.B_Identifiant
AND TABLE_A.A_Relation_B_ident is not null; |
ça évite le full access de suite sur table_B.
Problème, en hibernate, il n'aime pas du tout, vu que pour lui, le champ A_Relation_B_ident est une entité, et non un String ou autre...
Au moment de l'execution du code, j'ai le message suivant :
Citation:
Erreur dans la récupération des demandes pour la Recherche: with-clause expressions did not reference from-clause element to which the with-clause was associated
D'avance, je vous dis un grand merci !( déjà pour lire ce post...)