Hello,
When I run this:
Code:
List traces = getSessionMAJA().createCriteria(TraceStatistiques.class).add( Expression.sql("lower({alias}.action) like upper(?)", "stat%", Hibernate.STRING) ).list();
The generated SQL resolves to:
Code:
select this.ACA_C_ID as ACA_C_ID0_, this.ACA_D_DATE as ACA_D_DATE0_, this.ACA_C_ID_AGENT as ACA_C_ID5_0_, this.ACA_A_NOM_AGENT as ACA_A_NO3_0_, this.ACA_A_ACTION as ACA_A_AC4_0_, this.ACA_N_SERVICE_AGENT as ACA_N_SE6_0_, this.ACA_A_TYPE_STAT as ACA_A_T14_0_ from ACT_AGENT this where lower(this.action) like upper(?)
which is invalid
Quote:
ORA-00904: "THIS"."ACTION": invalid identifier
)
However putting the column name directly in the lower() function, generates the right SQL:
Code:
List traces = getSessionMAJA().createCriteria(TraceStatistiques.class).add( Expression.sql("lower({alias}.ACA_A_ACTION) like upper(?)", "stat%", Hibernate.STRING) ).list();
which resolves correctly to:
Code:
select this.ACA_C_ID as ACA_C_ID0_, this.ACA_D_DATE as ACA_D_DATE0_, this.ACA_C_ID_AGENT as ACA_C_ID5_0_, this.ACA_A_NOM_AGENT as ACA_A_NO3_0_, this.ACA_A_ACTION as ACA_A_AC4_0_, this.ACA_N_SERVICE_AGENT as ACA_N_SE6_0_, this.ACA_A_TYPE_STAT as ACA_A_T14_0_ from ACT_AGENT this where lower(this.ACA_A_ACTION) like upper(?)
My question:
How can I avoid hardcoding the column name (ACA_A_ACTION) in my Hibernate query?
Thanks.