Subject | Re: [Firebird-Java] Jaybird problems using hibernate |
---|---|
Author | Mark Rotteveel |
Post date | 2013-11-02T10:10:02Z |
On 27-10-2013 22:29, Danny García Hernández wrote:
cases like 2111, similar if you chop off the last character and use
%111, then you would miss cases like 1112. And even then it won't
address cases with more complicated patterns.
I'd strongly suggest not to use hackish solutions in the driver, but
instead expand the column to be a bit wide. If the current length is
really important: add a check constraint to enforce it.
I am not too happy with the existence of FBWorkaroundStringField and
like to remove it entirely.
Mark
--
Mark Rotteveel
> I change this code in FBWorkaroundStringField.java, if data is greaterThe server only receives up to the declared length of the column.
> than sqllen but minor or equal than sqllen + 2, and have a begining or
> ending '%', i consider the value as good.
>
> public void setString(String value) throws SQLException {
> byte[] data = setStringForced(value);
>
> if (value == STRING_NULL_VALUE)
> return;
> if (data.length > field.sqllen && !isSystemTable(field.relname)) {
> // special handling for the LIKE ? queries with CHAR(1) fields
> if (!(value.length() <= field.sqllen + 2 &&
> (value.charAt(0) == '%' || value.charAt(value.length() - 1) == '%')))
> throw new DataTruncation(-1, true, false, data.length,
> field.sqllen);
> }
> }
>
> But this only disallow the exception, select don't return any result,
> maybe because server can´t read the correct value from parameters
> structure passed from jaybird.
> My initial idea was extract % character from de data value if valueThe problem is this misses cases eg %111% change to 111% and it misses
> length was greater than field legnth:
>
> Field Length: varchar(4).
> Search for: 11 (%11%). OK. (Containing)
> Search for: 111 (%111%). ERROR. Extract first % (111%). OK. (Starting)
> Search for: 1111 (%1111%). ERROR. Extract first and last % (1111). OK.
> (Equal)
>
> I know that search logic change as a function of the length of search
> string, but for us, is better than only search for two characters (is
> this case).
cases like 2111, similar if you chop off the last character and use
%111, then you would miss cases like 1112. And even then it won't
address cases with more complicated patterns.
I'd strongly suggest not to use hackish solutions in the driver, but
instead expand the column to be a bit wide. If the current length is
really important: add a check constraint to enforce it.
I am not too happy with the existence of FBWorkaroundStringField and
like to remove it entirely.
Mark
--
Mark Rotteveel