Skip to content
Advertisement

Substring in select statement in JPQL

I’m trying to select a substring of column, i.e. select substring(description, 1, 200) from category where id=1

Is it possible to have a substring function within a select statement in JPQL/JPA 2? If yes, how? If no, are there any alternatives? Thanks.

Advertisement

Answer

There is a scalar expression for this: SUBSTRING(string, start, end)

I believe this is allowed in the SELECT clause in JPA 2.0, but not in JPA 1.0.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement