Equivalent to sql function LEFT () in JPA

1

What is the equivalent function of LEFT () in JPA?

I need to get only the first 6 characters of a field.

The equivalent select in sql would be:

select  left(campo,6), count(*) qtd
from tabela
group by left(campo,6)
    
asked by anonymous 11.08.2017 / 22:25

1 answer

1

There is no LEFT () function in jpa!

The documentation restricts the capture of string portions only to the SUBSTRING () function.

ex:

select substring(v.campo, 1, 6), count(*)
from V v
group by substring(v.campo, 1, 6)
    
11.08.2017 / 22:56