-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Joins and objects
PostPosted: Tue May 18, 2004 4:48 pm 
Newbie

Joined: Tue May 18, 2004 4:17 pm
Posts: 4
Location: Cypress California
How does Hibernate process a join result if the result has not been mapped to a defined class? For instance if my user table/mapping includes columns a b c, and my books table/mapping includes columns a d e, my join may look like the following:

select user.a, b, d, e from user, books where user.a = "xyz" and user.a = books.a;

I am assuming the answer is no, if so how can this situation be handled?

_________________
Thanks for your time,
Tom


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 4:53 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
select user.a, b, books.d, books.e from user, books where user.a = "xyz" and user.a = books.a

or
select user,book from user u, book b where u.a = "xyz" and u.a = b.a

you'll get Object[]


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 5:06 pm 
Newbie

Joined: Tue May 18, 2004 4:17 pm
Posts: 4
Location: Cypress California
Okay, what's in Object[]?

Is there documentation on this specific topic that I can reference?

_________________
Thanks for your time,
Tom


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 5:12 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
http://www.hibernate.org/hib_docs/reference/en/html/


select user,book from user u, book b where u.a = "xyz" and u.a = b.a
you'll get a list of object[]
list.get(0) = 1st result row
object[0] = user (you must cast it into user)
object[1] = book (you must cast it into book)


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 5:19 pm 
Newbie

Joined: Tue May 18, 2004 4:17 pm
Posts: 4
Location: Cypress California
Excellent!

Thanks!!

_________________
Thanks for your time,
Tom


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