ObjectDB ObjectDB

substring works with string but not with char


i want to select all entities whose name starts with a specific letter, i can use this query with a string parameter

select f from Foo f where substring(f.name, 1, 1) = ?1

but when i use a char, the query does not return anything.

i think it should also be possible to use char/Character types, do you agree?


I am not sure that this comparison is valid, since the type of the left side expression is String and the type on the right side expression (the parameter) is Character.

In ObjectDB as in Java char is comparable to int but not to String.

Maybe an exception has to be thrown on attempt to set a non String value for the parameter in this case.

ObjectDB Support

yes, i changed my mind and agree with you. throwing an exception is this case is good idea ;)



To post on this website please sign in.