]
Gail Badner updated HHH-5803:
-----------------------------
Fix Version/s: 4.0.0.Alpha1
3.6.1
ValueHandlerFactory fails to convert from java.lang.Long to
java.lang.Number
----------------------------------------------------------------------------
Key: HHH-5803
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5803
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager, query-criteria
Affects Versions: 3.6.0
Environment: Hibernate 3.6.0, Microsoft SQL Server 2008 R2
Reporter: Jens Rydholm
Fix For: 3.6.1, 4.0.0.Alpha1
When using the criteria builder to compare the quotient between two database columns with
a Long value from the Java code, Hibernate is unaware of how to convert from a Long to a
Number (despite Long being a subclass of Number). Pseudocode and exception stacktrace
included below.
CriteriaBuilder builder = ...;
Path<Long> longPath = ...;
Path<Float> floatPath = ...;
Long aLong = 250000000L;
builder.ge(builder.quot(longPath, floatPath), aLong);
java.lang.IllegalArgumentException: Unaware how to convert value [250000000 :
java.lang.Long] to requested type [java.lang.Number]
at
org.hibernate.ejb.criteria.ValueHandlerFactory.unknownConversion(ValueHandlerFactory.java:259)
at
org.hibernate.ejb.criteria.ValueHandlerFactory.convert(ValueHandlerFactory.java:287)
at
org.hibernate.ejb.criteria.predicate.ComparisonPredicate.<init>(ComparisonPredicate.java:88)
at
org.hibernate.ejb.criteria.CriteriaBuilderImpl.ge(CriteriaBuilderImpl.java:534)
...
Can be worked around by using builder.toLong to wrap builder.quot, like this:
builder.ge(builder.toLong(builder.quot(longPath, floatPath)), aLong);
Due to time constraints and the existing workaround, a test case can unfortunately not be
provided at this time.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: