[hibernate-dev] SUBSTRING example in documentation uses start position 0 instead of 1.

Mark Rotteveel mark at lawinegevaar.nl
Sat Feb 11 09:28:22 EST 2017


I'm still working on getting tests working for Firebird.

One of the tests that fails is the documentation test 
org.hibernate.userguide.hql.HQLTest.test_hql_substring_function_example

The reason this test fails is that Firebird hasn't implemented the 
SQL:2011 requirement that start positions lower than 1 should be handled 
as 1. See: http://tracker.firebirdsql.org/browse/CORE-5480

The example code is:

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.

Any objections if I prepare a pull request to change this example to use 
1 and the related documentation to specify that start position is 1-based?

Or is there a specific reason this example uses 0?

Mark
-- 
Mark Rotteveel


More information about the hibernate-dev mailing list