Hibernate version: 3.1.3 and 3.2.0.cr4
Name and version of the database you are using: Firebird 1.5.3, JayBird 2.0.1 and 2.1.0 (embedded).
Driver class:: org.firebirdsql.jdbc.FBDriver
Hi,
The problem:
like queries throw DataTruncation exceptions or produce empty results when the search text reachs the column length or the column length -1.
What I try to do is:
Code:
Restrictions.like("fieldName", "%" + filter + "%")
or:
Code:
Restrictions.like("fieldName", filter, MatchMode.ANYWHERE)
Over a VARCHAR field. The generated result is as simple as:
Code:
... where fieldName like ?
A) With JayBird 2.0.1 and Hibernate (3.1.3 or 3.2.0-rc4)
I get a DataTruncation exception:
Code:
Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2148)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
...
Caused by: java.sql.DataTruncation: Data truncation
at org.firebirdsql.jdbc.field.FBWorkaroundStringField.setString(FBWorkaroundStringField.java:95)
at org.firebirdsql.jdbc.AbstractPreparedStatement.setString(AbstractPreparedStatement.java:383)
at org.hibernate.type.StringType.set(StringType.java:26)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1514)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1576)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
... 16 more
B) With JayBird 2.1.0 and Hibernate (3.1.3 or 3.2.0-rc4)
No exception is thrown, but the query produces an empty result when there should be matches.
Am I doing something wrong or stupid? Should I file a bug report for it?
Regards.