Bonjour,
j'ai un souci, je souhaite réaliser une grosse requête HQL qui ramène toute une grappe d'objet, le tout dans un fichier xml (Reader d'un Spring Batch)
Le mapping de VueAutomateED :
Cette requête renvoi les bons résultats si je ne ramène qu'un seul automate. Les résultats sont incohérents à partir de 2. (par exemple, le 2ème automate n'a qu'une connexion au lieu des 2 réelles, 1 seule anomalie au lieu de 300...)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 <class name="com.mycompany.entity.VueAutomateED" table="VUEAUTOMATE"> <id name="id" type="long"> <column name="ID" precision="22" scale="0" /> <generator class="sequence"> <param name="sequence">SEQ_AUTOMATE</param> </generator> </id> <property name="numSerie" type="string"> <column name="NUM_SERIE" length="8" /> </property> <property name="id_auto_complet" type="string"> <column name="ID_AUTO_COMPLET" length="15" /> </property> <many-to-one name="entiteED" class="com.mycompany.entity.EntiteED" fetch="select"> <column name="ENTITE_ID" precision="22" scale="0" /> </many-to-one> <many-to-one name="generationAutomateED" class="com.mycompany.entity.GenerationAutomateED" fetch="select"> <column name="GENERATION_AUTOMATE_ID" precision="22" scale="0" /> </many-to-one> <set name="tempIndispos" inverse="true" > <key> <column name="AUTOMATE_ID" precision="22" scale="0" /> </key> <one-to-many class="com.mycompany.entity.TempIndispoED" /> </set> <set name="listHistoAnomalies" inverse="true" > <key> <column name="AUTOMATE_ID" precision="22" scale="0" /> </key> <one-to-many class="com.mycompany.entity.HistoAnomalieED" /> </set> <set name="listHistoIndispos" inverse="true" > <key> <column name="AUTOMATE_ID" precision="22" scale="0" /> </key> <one-to-many class="com.mycompany.entity.HistoIndispoED" /> </set> <set name="listConnexions" inverse="true" > <key> <column name="AUTOMATE_ID" precision="22" scale="0" /> </key> <one-to-many class="com.mycompany.entity.ConnexionED" /> </set> </class>
La requête HQL comme écrite dans mon fichier Xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 from VueAutomateED a join fetch a.generationAutomateED gen join fetch gen.modeleAutomateED mod join fetch mod.modes join fetch a.entiteED ent left join fetch a.listHistoAnomalies ano join fetch ano.anomalie left join fetch a.listConnexions connex left join fetch a.listHistoIndispos indispos where to_char(ano.dateDebutAnomalie,'YYYYMMDD') <= '#{jobParameters[dateFinPlage]}' and to_char(ano.dateFinAnomalie,'YYYYMMDD') >= '#{jobParameters[dateDebutPlage]}' and (mod.libelle = '#{jobParameters[modeleAutomate]}') and (a.id = 30842 or a.id = 30841) order by a.id
La requête SQL générée :
Auriez vous une idée svp ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 select vueautomat0_.ID as ID3_0_, generation1_.ID as ID8_1_, modeleauto2_.ID as ID9_2_, modeexecut4_.ID as ID13_3_, entiteed5_.ID as ID12_4_, listhistoa6_.ID as ID5_5_, anomalieed7_.ID as ID4_6_, listconnex8_.ID as ID1_7_, listhistoi9_.ID as ID7_8_, vueautomat0_.NUM_SERIE as NUM2_3_0_, vueautomat0_.ID_AUTO_COMPLET as ID3_3_0_, vueautomat0_.ENTITE_ID as ENTITE4_3_0_, vueautomat0_.GENERATION_AUTOMATE_ID as GENERATION5_3_0_, generation1_.LIBELLE as LIBELLE8_1_, generation1_.CODE_TYPE_ACORES as CODE3_8_1_, generation1_.MODELE_AUTOMATE_ID as MODELE4_8_1_, modeleauto2_.LIBELLE as LIBELLE9_2_, modeexecut4_.LIBELLE as LIBELLE13_3_, modes3_.modele_id as modele1_0__, modes3_.mode_id as mode2_0__, entiteed5_.LIBELLE as LIBELLE12_4_, entiteed5_.CODE_REGATE as CODE3_12_4_, listhistoa6_.DATE_DEBUT as DATE2_5_5_, listhistoa6_.AUTOMATE_ID as AUTOMATE3_5_5_, listhistoa6_.DATE_FIN as DATE4_5_5_, listhistoa6_.ANOMALIE_ID as ANOMALIE5_5_5_, listhistoa6_.AUTOMATE_ID as AUTOMATE3_1__, listhistoa6_.ID as ID1__, anomalieed7_.LIBELLE as LIBELLE4_6_, anomalieed7_.CODE_EVENEMENT as CODE3_4_6_, anomalieed7_.RESPONSABILITE_ID as RESPONSA4_4_6_, anomalieed7_.MODE_EXECUTION_ID as MODE5_4_6_, anomalieed7_.MODELE_AUTOMATE_ID as MODELE6_4_6_, listconnex8_.AUTOMATE_ID as AUTOMATE2_1_7_, listconnex8_.DATE_CONNEXION_SUPERVISION as DATE3_1_7_, listconnex8_.DATE_INTEGRATION_SUPERVISION as DATE4_1_7_, listconnex8_.DATE_DECONNEXION_SUPERVISION as DATE5_1_7_, listconnex8_.AUTOMATE_ID as AUTOMATE2_2__, listconnex8_.ID as ID2__, listhistoi9_.DATE_DEBUT as DATE2_7_8_, listhistoi9_.DATE_FIN as DATE3_7_8_, listhistoi9_.INDISPONIBILITE_ID as INDISPON4_7_8_, listhistoi9_.AUTOMATE_ID as AUTOMATE5_7_8_, listhistoi9_.AUTOMATE_ID as AUTOMATE5_3__, listhistoi9_.ID as ID3__ from VUEAUTOMATE vueautomat0_ inner join GENERATIONS_AUTOMATES generation1_ on vueautomat0_.GENERATION_AUTOMATE_ID=generation1_.ID inner join MODELES_AUTOMATES modeleauto2_ on generation1_.MODELE_AUTOMATE_ID=modeleauto2_.ID inner join MODE_MODELE modes3_ on modeleauto2_.ID=modes3_.modele_id inner join MODES_EXECUTION modeexecut4_ on modes3_.mode_id=modeexecut4_.ID inner join ENTITES entiteed5_ on vueautomat0_.ENTITE_ID=entiteed5_.ID left outer join HISTORIQUE_ANOMALIES listhistoa6_ on vueautomat0_.ID=listhistoa6_.AUTOMATE_ID inner join ANOMALIES anomalieed7_ on listhistoa6_.ANOMALIE_ID=anomalieed7_.ID left outer join HISTORIQUE_CONNEXIONS listconnex8_ on vueautomat0_.ID=listconnex8_.AUTOMATE_ID left outer join HISTORIQUE_INDISPONIBILITES listhistoi9_ on vueautomat0_.ID=listhistoi9_.AUTOMATE_ID where to_char(listhistoa6_.DATE_DEBUT, 'YYYYMMDD')<='20110930' and to_char(listhistoa6_.DATE_FIN, 'YYYYMMDD')>='20110901' and modeleauto2_.LIBELLE='LISA' and ( vueautomat0_.ID=30841 or vueautomat0_.ID=30842 ) order by vueautomat0_.ID
Partager