[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2851?page=c...
]
Kala Bala commented on HHH-2851:
--------------------------------
hello everybody,
I have the same problem when I try to set null to param value which expects long, integer,
short, ect. not with string.
Does anyone know how to work-around the problem,
I use 3.3.1.GA version of Hibernate and Oracle 10g driver.
Thank you in advance
ParameterTranslationsImpl fails to correctly determine parameter
type
---------------------------------------------------------------------
Key: HHH-2851
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2851
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5
Reporter: Alex Savitsky
Priority: Minor
Attachments: HibernateTestCase.zip, patch.txt
For the conditions in the form "(:param IS NULL OR alias.someField = :param)",
the HQL parses would not correctly determine the type of param, unless the conditions are
swapped like "(alias.someField = :param OR :param IS NULL)". The reason is that
NamedParamTempHolder classes are created for all parameter entries, in the order they
appear in the query. The first occurrence (:param IS NULL) would have its expectedType set
to null, and the second occurrence would use the param holder created by the first
occurrence, without checking whether it can improve it in any way (which it can - the
expectedType for second occurrence is correctly determined to be Long).
Proposed fix would be to check for this particular condition, enhancing paramHolder if
possible, with new information:
old code:
if ( paramHolder == null ) {
paramHolder = new NamedParamTempHolder();
paramHolder.name = namedSpec.getName();
paramHolder.type = namedSpec.getExpectedType();
namedParameterMap.put( namedSpec.getName(), paramHolder );
}
new code:
if ( paramHolder == null ) {
paramHolder = new NamedParamTempHolder();
paramHolder.name = namedSpec.getName();
paramHolder.type = namedSpec.getExpectedType();
namedParameterMap.put( namedSpec.getName(), paramHolder );
+ } else if (paramHolder.getExpectedType() == null &&
namedSpec.getExpectedType() != null) {
+ paramHolder.type = namedSpec.getExpectedType();
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira