java - transform sql(oracle) to detachedCriteria(Hibernate) -


i want trasform select hibernate dont know how can it. need select group diferent dates (not hours).

select         distinct to_char(fecha_emision,'dd/mm/yyyy')  tb_bce_sigpes  order to_char(fecha_emision,'dd/mm/yyyy') desc 

i try can´t more (i don't know how). need put inside "to_char":

detachedcriteria query = detachedcriteria.forclass(tbbcesigpe.class); query.setprojection(projections.distinct(projections.property("fechaemision"))); query.addorder(order.asc("fechaemision")); 

you try projections.sqlprojection:

    detachedcriteria query = detachedcriteria.forclass(tbbcesigpe.class);     query.setprojection(             projections.distinct(                     projections.sqlprojection(                             "to_char(fecha_emision,'dd/mm/yyyy')",                              new string[]{"fechaemision"},                              new type[]{stringtype.instance}                             )));     query.addorder(order.asc("fechaemision")); 

in older versions of hibernate should use hibernate.string instead of stringtype.instance.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -