SUBSTRING example code suggests start position is 0-based

Description

The substring example code is in the documentation:

1 2 3 4 5 List<String> prefixes = entityManager.createQuery( "select substring( p.number, 0, 2 ) " + "from Call c " + "join c.phone p", String.class ) .getResultList();

However this example is slightly confusing in that it implies that start position is 0-based, while both SQL and JPA 2.1 (section 4.6.17.2.1) make clear it should be 1-based.

The example code should be updated to use start position 1, and the documentation should explicitly mention that it is 1-based.

Environment

None

Status

Assignee

Mark Rotteveel

Reporter

Mark Rotteveel

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.2.7

Priority

Minor