-->
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: session.getNamedQuery returns nulls
PostPosted: Mon Sep 12, 2005 2:22 pm 
Beginner
Beginner

Joined: Thu Jul 28, 2005 1:19 pm
Posts: 24
Hello Everyone
Hibernate 3.0
I have a named query that is executed like :
Query q = session.getNamedQuery("stat.between.dates");
q.setDate(0, startDate);
q.setDate(1, endDate);

Now when I list like q.list, I get the size of the list as 830 which is the right count. However when I iterate the list I get null for all entries in the list (the 830). Any help is appreciated. I do n't know even how to troubleshoot this thing. The query looks correct, and most important is the number of members of this list. It does match what the query should return back; I mean the number of matches.

The way I get the list is q.list().

Iterator it = q.iterate();
MyObject ob = null;
while(it.hasNext()){
ob = (MyObject) it.next();
System.out.println(ob); ---> output null
}

Thank You


Top
 Profile  
 
 Post subject: found the problem
PostPosted: Mon Sep 12, 2005 7:19 pm 
Beginner
Beginner

Joined: Thu Jul 28, 2005 1:19 pm
Posts: 24
My mapping file through midlegen include every column in the primary key since I do not have one (I have foreign keys). Some of the rows included empty (null) value, and therefore the results return were null. To fix the problem I remapped my file and modified the value of the primary key.

Thank You all


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.