-->
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.  [ 7 posts ] 
Author Message
 Post subject: ClassCastException: what does join return?
PostPosted: Sat Jun 05, 2004 8:48 am 
Beginner
Beginner

Joined: Tue Mar 23, 2004 4:18 pm
Posts: 45
Hi!

I ran a

"SELECT urls.url, urls.id, html.html FROM f4t.hibernate.Url as urls JOIN urls.html as html" and expected to get Url objects, but casting to Url does actually throw an ClassCastExceptin (html.urlid is FK to urls.id):

Code:
Iterator iter = session.iterate(query);
while( iter.hasNext() )
{
   Url o= (Url)iter.next();   // ClassCastException
   System.out.println(o);
}


Well, what does my query return actually?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 05, 2004 8:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Collection of Object[], you are using projection.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 05, 2004 10:20 am 
Beginner
Beginner

Joined: Tue Mar 23, 2004 4:18 pm
Posts: 45
And what would I have to do to actually get Url objects (I assume this would incorporate fetching all columns?)?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 05, 2004 10:21 am 
Beginner
Beginner

Joined: Tue Mar 23, 2004 4:18 pm
Posts: 45
christian wrote:
Collection of Object[], you are using projection.


Can I somehow get a col name to array index mapper? What if somebody changes the sequence or does add/remove columns to the query?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 05, 2004 10:27 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please read about the "select" clause in the Hibernate documentation.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 05, 2004 10:45 am 
Beginner
Beginner

Joined: Tue Mar 23, 2004 4:18 pm
Posts: 45
I did

SELECT urls FROM f4t.hibernate.Url as urls JOIN urls.html as html"
WHERE urls.url LIKE 'http://%'"

But this leads to numerous SELECT query executed :-( I played with use_outer_join but this made thing even worse.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 05, 2004 12:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Without any of your mappings, we can only guess. But I think a safe guess is that you have all your associations defined as non-lazy. Please read the documentation!


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