Hibernate version:3.1.3
Name and version of the database you are using: Firebird 1.5
Hi,
I have a Criteria like this:
Code:
criteria.add(Restrictions.like("fieldName",
"%" + partialText + "%"));
When
partialText has the maximum field length (or the maximum length - 1) I get a DataTruncationException. I think that hibernate is adding 2 to
partialText length, one for every %.
Is it correct to query for
%partialText% when partialText has the maximum field length - 1 or the maximum length? A workaround is to query for
%partialText or
partialText% when it reachs the maximum length - 1, and to query with eq when it reachs the maximum length, but it is quite tedious.
The exception I get is:
Code:
org.hibernate.type.NullableType nullSafeSet
INFO: could not bind value '%1122334455%' to parameter: 4; Data truncation
06-sep-2006 16:40:34 org.hibernate.util.JDBCExceptionReporter logExceptions
ADVERTENCIA: SQL Error: 0, SQLState: 01004
06-sep-2006 16:40:34 org.hibernate.util.JDBCExceptionReporter logExceptions
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)
at com.psleuropa.paco.models.common.handlers.decla.DeclaracionDECLAHandler.listDeclaracionFilterCriteria(DeclaracionDECLAHandler.java:473)
at com.psleuropa.paco.models.common.handlers.decla.DeclaracionDECLAHandler.listDeclaraciones(DeclaracionDECLAHandler.java:277)
... 9 more
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