SQL to HQL ‘start with’ and ‘Connect by Prior’

grailshqlsql

I need to find a way to get the ids starting with 11, in sql is with 'start with' and 'Connect by prior' but in HQL, how can I do that?, if there is a better way in grails, the help would be great, thanks!

(Updated: Sorry, I didn't write the other command which is: 'connect by prior')

Best Answer

Assuming the ID is a string, why not simply use a like clause:

where id like '11%'

Assuming it's not a string, you could cast it to a string:

where cast(id as STRING) like '11%'

or

where str(id) like '11%'