Improve the collection of the parameter meta data.
--------------------------------------------------
Key: HHH-2406
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2406
Project: Hibernate3
Type: Improvement
Components: query-hql
Versions: 3.2.2
Environment: WindowsXP + JBoss 3.2.6 + Spring
Reporter: Bryan Brouckaert
Currently the meta data of a parameter is collected with the first occurence of the
parameter and is never updated afterward, this gives some strange effects in certain
cases.
If you have the following classes:
<class name="Contract">
<id name="id">
<generator class="native"/>
</id>
<many-to-one name="type" property-ref="key" >
<column name="type" length="64"/>
</many-to-one>
</class>
<class name="AgreementType">
<id name="id">
<generator class="native" />
</id>
<property name="key" unique="true"
length="64"/>
<property name="value" />
</class>
Then the following HQL will fail:
select c from Contract c where ( :type is null or c.type = :type )
I found out that is it is because the "id" of the type is provided as JDBC
parameter and not the value.
The following fixes the problem:
select c from Contract c where ( c.type = :type or :type is null )
See the different order of the conditions? This time the "value" of the type is
provided as JDBC parameter (and everything works). The reason is simple, since in the
first HQL the first instance of the parameter is not applied on the c.type property the
"property-key" information is not taken into account.
I think that hibernate should be able to execute both statements. It seems to me that
when a parameter is encounterd a second time Hibernate should add the extra meta data.
--
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