hibernated icon indicating copy to clipboard operation
hibernated copied to clipboard

Is it possible to execute mysql functions using hql?

Open michaelc37 opened this issue 12 years ago • 1 comments

i tried to execute CURRENT_DATE(), and UPPER() but i get errors:

"Alias name identifier expected in FROM clause near ...." "No property CURRENT_DATE found in entity ...."

here is the code i tried;

  1. string cmdtext = format( "FROM searchquerymodules AS sqm\r\n" ~ "JOIN sqm.searchquery AS sq\r\n" ~ "JOIN sqm._module AS m\r\n" ~ "WHERE (m.active = 1) and (m.id = %d)" ~ " and ((sq.expirydate is null) or (sq.expirydate > CURRENT_DATE()))", moduleid);
Query q = session.createQuery(cmdtext);

return q.list!searchquerymodules();
  1. string cmdtext = format( "FROM notifications n\r\n" ~ "JOIN n.searchquerymodule as sqm\r\n" ~ "JOIN sqm.searchquery as sq\r\n" ~ "WHERE sq.account_id = %d \r\n" ~ " and sqm.module_id = %d \r\n" ~ " and UPPER(n.url) = '%s' \r\n" ~ "", accountid, moduleid, toUpper(url));
   Query q = session.createQuery(cmdtext);
return q.list!notifications();

michaelc37 avatar Aug 03 '13 22:08 michaelc37

Not supported yet. Can be implemented in future.

buggins avatar Sep 26 '13 08:09 buggins