-->
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: ClassCastException
PostPosted: Tue Nov 08, 2005 12:05 pm 
Newbie

Joined: Thu Oct 27, 2005 3:06 am
Posts: 17
Hi all there,

I experienced a real strange behaviour within my hibernate application: I use the following code snipplet:

Session session = SessionUtil.getCurrentSession();
Criteria criteria = session.createCriteria(User.class);
List userList = criteria.list();

for (int i=0; i<userList.size(); i++)
{
User user = (User)userList.get(i);
System.out.println(user.getName());
}

...which is real simple; the problem is I always receive a ClassCastException in the marked line. But the userList-attribute contains values of the type User, I can see this by debugging the snipplet.

Can anybody tell me how to fix this exception?

Cheers, Florian!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 4:19 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
A User class from an other package?`

HTH
Ernst


Top
 Profile  
 
 Post subject: Need Help
PostPosted: Thu Nov 10, 2005 10:22 pm 
Newbie

Joined: Thu Nov 10, 2005 2:13 am
Posts: 1
Location: Jakarta
Hi all there,

try
{
Session session = factory.openSession();
tx = session.beginTransaction();

List list1 = session.createQuery("FROM People as play, Agama as rel WHERE play.id = :var")
.setString("var", a)
.list();

Iterator i=list1.iterator();

while(i.hasNext())
{
People people1 = (People)i.next();
out.println(people1.getId());

session.clear();

Agama agama1 = (Agama)i.next();
out.println(agama1.getReligi());
}

... Me too, I always get Exception like this java.lang.ClassCastException: [Ljava.lang.Object;
i don't know how to show the request that i want like agama1.getReligi() from two tables that i join ....?

please help ....? my english is not so good, thank's he2x

handi.....?

_________________
hi i'm beginner would learn much about web programming design...thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 1:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
such questions are for the user forum. But try and cast it to an Object[] and get the result from there.

_________________
Max
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.  [ 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.