-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Subselect fetch and query named parameters problem
PostPosted: Tue Jul 26, 2005 10:04 am 
Newbie

Joined: Tue Jul 26, 2005 6:16 am
Posts: 2
Location: Russia, Moscow
Hi!

I'm trying to use subselect fetching for one-to-many collections. It works fine for loading single objects.
But if I trying to use object with subselect fetch collection in query with named parameters, collection loading fails with еrror "org.hibernate.util.JDBCExceptionReporter - Parameter #1 has not been set."

Detailed information:
I'm using Hibernate 3.0.5

Mapping document:
Code:
<hibernate-mapping>
    <class name="ru.masterbit.odc.beans.Client" table="CLIENT" lazy="true">
        ....
        <set name="consultations" fetch="subselect" inverse="true" lazy="true">
            <key column="client_id"/>
            <one-to-many class="ru.masterbit.odc.beans.ConsultationMicro"/>
        </set>
        ....   
    </class> 
</hibernate-mapping>


Java code:
Code:
this.lastNameHql = "%x%";

String query = "SELECT DISTINCT client FROM Client as client LEFT JOIN client.consultations as cons WHERE client.lastName like :lastNameHql";

Query hibernateQuery = sess.createQuery(query).setProperties(this); // <-- 'this' object have getter getLastNameHql(), so this parameter is definitely present
List clients = hibernateQuery.list(); // <-- Query works fine, parameter :lastNameHql properly passed

Client client = (Client)clients.get(0);
client.getConsultations(); // <-- EXECEPTION HERE !!!


Application log trace:
Code:
Hibernate: /* load one-to-many ru.masterbit.odc.beans.Client.consultations */ select consultati0_.client_id as client4_1_, consultati0_.id as id1_, consultati0_.id as id0_, consultati0_.dateReal as dateReal5_0_, consultati0_.membership_id as membership3_5_0_, consultati0_.client_id as client4_5_0_, consultati0_.cons_id as cons5_5_0_, consultati0_.result as result5_0_, consultati0_.entrust as entrust5_0_ from CONSULTATION_MICRO consultati0_ where consultati0_.client_id in (select client0_.id from CLIENT client0_ left outer join CONSULTATION_MICRO consultati1_ on client0_.id=consultati1_.client_id where client0_.lastName like ?)
[13:51:54.132]  WARN org.hibernate.util.JDBCExceptionReporter  - SQL Error: 0, SQLState: 07000
[13:51:54.148] ERROR org.hibernate.util.JDBCExceptionReporter  - Parameter #1 has not been set.


The problem is: class SubselectOneToManyLoader don't overrides Loader.bindNamedParameters(). Default Loader.bindNamedParameters() does nothing.
Possible fix for this problem is to override this method, like class QueryLoader do.
Should I post this request to Hibernate JIRA?

Thank you.

--
Arthur Suilin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 6:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Try in 3.1 beta 1 and if it still occurs, submit a runnable test case to JIRA.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 6:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I fixed this in CVS.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.