[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2851) ParameterTranslationsImpl fails to correctly determine parameter type

Manolo Burgos (JIRA) noreply at atlassian.com
Tue Feb 24 04:01:39 EST 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2851?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32486#action_32486 ] 

Manolo Burgos commented on HHH-2851:
------------------------------------

Hi, someone have idea when  this bug go to be added in Hibernate?

> 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list