For example, I have a table (Oracle) myTablewith a field myFieldthat is a CHARlength 5.
If I try to request something like below directly in sql dev or some other tools
SELECT * FROM myTable WHERE myField = 'aa'
I get some results as expected (note that I am comparing 'aa'with some db-padded values ββsuch as 'aa '(padded with three trailing spaces that match 5), etc.
Problem:
If I try to execute such a query using JPA Hibernate, for example, I do not get the same results (not even) UNLESS I either TRIMCHAR field before comparison, as
SELECT * FROM myTable WHERE TRIM(myField) = 'aa'
OR
I use my parameter (but this requires that I know the length of the CHAR), for example
FROM myTable WHERE TRIM(myField) = 'aa '
Questions: Are the two above my options? I am pleased to welcome more options aside from the above. Who has the best performance? Thank.
source
share