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

Vlad Mihalcea mihalcea.vlad at gmail.com
Sat Feb 11 09:56:57 EST 2017


Hi Mark,

Good catch. We should change it to 1, instead of 0.

Vlad

On Sat, Feb 11, 2017 at 4:28 PM, Mark Rotteveel <mark at lawinegevaar.nl>
wrote:

> 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
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list