[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2851?page=c...
]
Diego Pires Plentz commented on HHH-2851:
-----------------------------------------
Alex, you can download the source code from
http://anonsvn.jboss.org/repos/hibernate/
(more info at
http://www.hibernate.org/6.html). Please, attach a runnable test case and
(if you can) the patch that you proposed.
ParameterTranslationsImpl fails to correctly determine parameter
type
---------------------------------------------------------------------
Key: HHH-2851
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2851
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5
Reporter: Alex Savitsky
Priority: Minor
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