-->
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: Hibernate ClassCastException
PostPosted: Mon Jan 08, 2007 7:09 am 
Newbie

Joined: Mon Jan 08, 2007 6:39 am
Posts: 1
Hi,

I am trying to select a single column value from the table but i am getting the following exception .

This is a console based application and back end as MYSQL 5.0.

And java version as jdk1.4 and Hibernate version as Hibernate 3.0.

I have written query like this


bean app=new bean();
query="select mag.eno from bean mag";
q=session.createQuery(query);
for(Iterator it=q.iterate();it.hasNext();)
{
app=(bean)it.next();
System.out.println(app.getEno());
}


but i m getting error like this in the console

org.hibernate.impl.SessionFactoryImpl@5b8827
SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
Inserting Record
Hibernate: select bean0_.no as col_0_0_ from mag bean0_
Hibernate: select bean0_.no as col_0_0_ from mag bean0_
error:java.lang.ClassCastException


Help me


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 8:04 am 
Beginner
Beginner

Joined: Wed Aug 31, 2005 3:54 am
Posts: 45
The class retreived by this query is the class type of the column so not bean but string or integer ....

Don't forget to rate ;-)


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.