Because when you use the LOWER
function, its result doesn't have CHARACTER(255)
data type any more, it has CHARACTER VARYING
data type. Character string literals also have CHARACTER VARYING
data type in H2.
So a comparison between two CHARACTER VARYING values is actually performed and this comparison returns FALSE in H2 when strings have different length.
Without this function a comparison between CHARACTER(255) and CHARACTER VARYING values is performed and this comparison ignores trailing spaces in H2.
LOWER and UPPER functions should return result of the same data type as their argument according to the SQL Standard, but H2 currently cannot satisfy that requirement, because H2 doesn't have warnings. Some strings in some locales have different lengths after conversion to upper or lower case. If this length is larger than length of original data type, standard-compliant database should truncate the result to the declared length and raise a warning. But H2 cannot warn you about truncation and it is a bad idea to perform this truncation silently, so it isn't performed at all. But to return values longer than argument H2 declares result of these functions as CHARACTER VARYING with the maximum length.
Take a look on length and columnDefinition attributes of @Column annotation. You can adjust SQL data type produced by JPA with them.