java - How to use subquery into where clause? -


we integrate in query calculated field. calculated field obtained simple select max(x) table2.

but in our main query, if want filter on calculated field, had integrate in clause.

our problem integrate subquery where...in condition.

we try subqueries.in function problem cant inject list of value.

here sql request have.

select     this_.dmde_cee_id y0_,     this_.dt_dmde y1_,     (select         max(this0__.statut) y0_              cs_fc_dmde_cee this0__              this0__.dmde_cee_id=this_.dmde_cee_id limit 1 ) y16_      xxx this_       ( select         max(controledemandecee_.statut) y0_                      cs_fc_dmde_cee controledemandecee_                      controledemandecee_.dmde_cee_id=this_.dmde_cee_id     ) in (3,5)  order     this_.nom_dos asc,     this_.dt_dmde asc limit 10; 

here best result can have :

select     this_.dmde_cee_id y0_,     this_.dt_dmde y1_,     (select         max(this0__.statut) y0_              cs_fc_dmde_cee this0__              this0__.dmde_cee_id=this_.dmde_cee_id limit 1 ) y16_      xxx this_       5 in ( select         max(controledemandecee_.statut) y0_                      cs_fc_dmde_cee controledemandecee_                      controledemandecee_.dmde_cee_id=this_.dmde_cee_id     )  order     this_.nom_dos asc,     this_.dt_dmde asc limit 10; 

the java code criteria & subqueries :

final detachedcriteria dcontroledemande = detachedcriteria.forclass(controledemandebean.class, controle);         dcontroledemande.add(restrictions.eqproperty(controle_demande_id, dmd_id)); dcontroledemande.setprojection(projections.max(controle + ".statut.id"));  cdmd.add(subqueries.in(5l, dcontroledemandecee)) 

we can't replace 5l list/array of long.

any idea ? thanks

nb: have use criteria. client refuse native hql or sql.

you implement custom criterion renders like

( select         max(controledemandecee_.statut) y0_                      cs_fc_dmde_cee controledemandecee_                      controledemandecee_.dmde_cee_id=this_.dmde_cee_id ) in (5) 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -