The entity structure: waybill:task=1:N waybill:waybillNode=1:N The JPQL: {code:sql} select count(*) from com.yzt.microservice.core.ips.schema. ETask demo.EStudent as eTask eStudent inner join eTask eStudent . waybill clazz . waybillNodes teachers as eWaybillNode eTeacher on eWaybillNode eTeacher . nodeTime between '2016-03-02 00:00:00' and '2017-03-02 00:00:00' and eWaybillNode.nodeType name = ' allocation Alice ' where eTask.waybill.cardNo = 'aaa' {code}
The generate sql( This JPQL execute failure cause by "Unknown column 'eteacher3_.name_' in mysql,waybillnod2_ used before definition) 'on clause'". The generate sql : {code:sql} SELECT COUNT(*) estudent0_.id_ AS col_0_0_ id_1_41_0_, FROM etask_ etask0_ INNER JOIN ewaybill_ ewaybill1_ ON etask0_ eteacher3_ . waybill_id_=ewaybill1_. id_ AS id_1_72_1_, AND (( estudent0_.clazz_id_ AS clazz_id3_41_0_, waybillnod2_ estudent0_ . node_time_ BETWEEN '03/02/2016 00:00:00 name_ AS name_2_41_0_, eteacher3_ . 000' AND '03/02/2017 00:00:00.000' name_ AS name_2_72_1_ ) FROM AND waybillnod2_.node_type_='allocation') estudent_ estudent0_ INNER JOIN ewaybill_node_ waybillnod2_ eclass_ eclass1_ ON ewaybill1_ estudent0_ . id_ clazz_id_ = waybillnod2_ eclass1_ . waybill_id_ id_ WHERE AND ( ewaybill1_ eteacher3_ . card_no_ name_ =' aaa Alice ' {code} The correct sql should be like this: {code:sql} SELECT COUNT(* ) AS col_0_0_ FROM etask_ etask0_ INNER JOIN ewaybill_ ewaybill1_ eteacher_eclass_ teachers2_ ON etask0_ eclass1_ . waybill_id_ id_ = ewaybill1_ teachers2_ . id_ class_id_ INNER JOIN ewaybill_node_ waybillnod2_ eteacher_ eteacher3_ ON ewaybill1_ teachers2_ . id_ teacher_id_ = waybillnod2_ eteacher3_ . waybill_id_ id_ AND (( waybillnod2_.node_time_ BETWEEN '03/02/2016 00:00:00.000' AND '03/02/2017 00:00:00.000' ) AND waybillnod2_.node_type_='allocation') WHERE ewaybill1_.card_no_='aaa' {code} |
|