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

Alex Savitsky (JIRA) noreply at atlassian.com
Wed Sep 19 08:34:14 EDT 2007


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

Alex Savitsky commented on HHH-2851:
------------------------------------

Yes, and the class in question is org.hibernate.hql.ast.ParameterTranslationsImpl. I'll try to create a patch once I get the CVS connectivity straight...

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

        



More information about the hibernate-issues mailing list