[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2673) Collection <loader> doesn't support named hql queries

Luca Dall'Olio (JIRA) noreply at atlassian.com
Thu Jun 14 13:48:52 EDT 2007


Collection <loader> doesn't support named hql queries 
------------------------------------------------------

                 Key: HHH-2673
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2673
             Project: Hibernate3
          Issue Type: Bug
    Affects Versions: 3.2.4.sp1
         Environment: Hibernate 3.2.4 HSQLDB 1.8.0.1
            Reporter: Luca Dall'Olio


When mapping a "named HQL query loader" for a collection, you always get a "Named SQL query loader" Exception. The exception goes away just changing the <query> elemento into <sql-query> .

By looking at the source code in org.hibernate.persister.collection.NamedQueryCollectionInitializer
it looks like an unwanted limitation :

		AbstractQueryImpl query = (AbstractQueryImpl) session.getNamedSQLQuery(queryName); 

should be insted :

		AbstractQueryImpl query = (AbstractQueryImpl) session.getNamedQuery(queryName); 

This would make it work both for named HQL queries and for named SQL queries.

This is an example mapping :

<hibernate-mapping
        package="org.hibernate.test">

    <class name="A">
        <id>
            <generator class="native"/>
        </id>
        <property name="name" not-null="true"/>
        <set name="bees">

            <one-to-many class="B"/>
            <loader query-ref="qb"/>
        </set>

    </class>

    <class name="B">
        <id>
            <generator class="native"/>
        </id>
        <property name="name" not-null="true"/>
    </class>

    <query name="qb">
    select bee from B bee
    </query>

</hibernate-mapping>

-- 
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