Uploaded image for project: 'Hibernate ORM'
  1. HHH-11482

SUBSTRING example code suggests start position is 0-based

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.2.7
    • Fix Version/s: 5.2.8
    • Component/s: documentation
    • Labels:
      None
    • Last commented by a user?:
      true

      Description

      The substring example code is in the documentation:

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: