We are using grails-groovy with Hibernate, I have a SQL query like this in my grails controller
String markerCalcQuery =
"select sum(trans_cnt) as t_count, location from map2_data where "+
"fdate between (:datefrom) and (:dateto) "+
"and res_id=:res_id "+
"group by location ;"
res_row=gurculsql.rows(markerCalcQuery,[res_id:res_id,datefrom:format_dateprevious,dateto:format_datenow]);
How do I change this query to HQL, I don’t have a domain class map2_data, but want to know if I need to create it for converting this query to HQL, or can I convert it without doing that (should use gorm based implementation)?
I have many queries right now written for MySQL and I need to convert them to HQL.
I have now created the domain class map2_data. So how would the above query change (how to decide the functions… out of findallby, createcriteria, etc)
Regards,
Priyank
HQL works on Hibernate entities. If you don’t have an entity to map your table, you can’t use HQL on this table. That’s the principle of an ORM: use objects to represent tables.