-->
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.  [ 4 posts ] 
Author Message
 Post subject: Why the returned query results contain the same record?
PostPosted: Tue Jul 19, 2005 1:45 pm 
Newbie

Joined: Tue Jul 19, 2005 1:31 pm
Posts: 3
I am a new user and playing Hibernate 2.1.8. Everything seems OK except I got a strange returned query results. In order to get my first Hibernate code worked, I use a simple query statement something like Criteria crt = HibernateUtil.getSession().createCriteria(
Message.class);
crt.add(Expression.between("postedDate", start, end));
crt.add(Expression.eq("author", author));
crt.addOrder(Order.asc("postedDate"));
Collection c = crt.list();
logger.debug("# of records:" + c.size());
When I run my code, I did get results and the logger reports correct size. But the interesting thing is all records are identical (to the first one) if I display them. Then I use the Hibernate generated sql statement to manually run ang got results as expected.
My database is Oracle 9i.

Any comments? Thanks very much for your help.
Yongping


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 1:56 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
post your display code...maybe it's a get(0) instead of get(i)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 2:03 pm 
Newbie

Joined: Tue Jul 19, 2005 1:31 pm
Posts: 3
Actually I use
Iterator it = c.iterator();
while(it.hasNext())
{
msg = (Message)it.next();
logger.debug(msg.getTitle() + "|" + ...);
}
47 records are totally exactly the same.

Thanks for your info.

Y.P


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 2:27 pm 
Newbie

Joined: Tue Jul 19, 2005 1:31 pm
Posts: 3
OK. I got it fixed. Actually I made a mistake on id mapping. I thought key generator (in this case, only reading data out of from database) doesn't matter, so I use native (in fact, pk is defined as VARCHAR(12) in my database). I am proved wrong. it works fine if I changed it to uuid.hex.

Thanks
YP


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