-->
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: hibernate query returns String or Object, and not pojo.
PostPosted: Mon Apr 12, 2004 6:57 am 
Newbie

Joined: Mon Apr 05, 2004 3:14 am
Posts: 13
hi,

my code is as follows:

Query query = session.createQuery("select part_master.part_id from part_master as part_master ");

for (Iterator it = query.iterate(); it.hasNext();)
{
//FAILED HERE ?
part_master item = (part_master) it.next();
}

the cast to part_master pojo fails.
Dos console says :

Error:java.lang.String

2. if i returned more than one field in my sql, Hibernate returns Object.
and then again my cast to part_master fails.

3. same pojo , works ok in HibernateIde

any tips are welcome.

iyyappan


Top
 Profile  
 
 Post subject: solved thanks
PostPosted: Mon Apr 12, 2004 7:10 am 
Newbie

Joined: Mon Apr 05, 2004 3:14 am
Posts: 13
it returns an array of objects.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 10:16 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
it perfectly normal, read the doc about querying
if you want your pojo
Code:
Query query = session.createQuery("select part_master from part_master as part_master ");


or simply
Code:
Query query = session.createQuery("from part_master as part_master ");


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.