-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL and SQL results different?
PostPosted: Mon Oct 13, 2003 12:11 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 8:53 pm
Posts: 34
Hi,

I have the following query: Department and Student have bidirectional
many-to-many association.


Query query = session.createQuery("SELECT d.id, d.name, s.name, elements(d.students) "+
" FROM Department as d, Student as s "+
" WHERE d.id = ? and s.id = ?");

query.setString(1, "01");
query.setString(2, "00001");

List summaryList = query.list();

I got "java.lang.NullPointerException" for the above query. But when I use
the Hibernate generated sql code to run it on the commanline, it gives me
a list of results. I am puzzled at this phenomenon. Does that mean my HQL is correct since generated SQL code produces correct results? But why did it
give me a NullPointerException when I ran it? really need enlihtment on this.

thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2003 1:19 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 8:53 pm
Posts: 34
Figure it out. Row starts from 0. My bad.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.