-->
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: Can a component be feteched by HQL?
PostPosted: Sun Sep 06, 2009 12:51 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 3:36 pm
Posts: 78
I currently don't have a test environment for this question. So, I ask it instead. I have a component Address in an entity Account.
Code:
@Embeddable
public class Address implements java.io.Serializable {
...
}

@Entity
@Table(name = "account")
public class Account implements java.io.Serializable {
...
   private Address address;
...
}

Can I retrieve an address with a HQL something like the following
Code:
select account.address from Account account where ...

instead of
Code:
from Account account where ...

and retrieve the Address from the result?


Top
 Profile  
 
 Post subject: Re: Can a component be feteched by HQL?
PostPosted: Sun Sep 06, 2009 1:07 pm 
Beginner
Beginner

Joined: Fri Oct 28, 2005 10:46 am
Posts: 37
Google turns this up as its top result:
http://docs.jboss.org/hibernate/stable/ ... components


Top
 Profile  
 
 Post subject: Re: Can a component be feteched by HQL?
PostPosted: Sun Sep 06, 2009 6:34 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Why not just load the object and use the getter, so account.getAddresses(). That would be easier and more object oriented!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Can a component be feteched by HQL?
PostPosted: Mon Sep 07, 2009 4:17 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 3:36 pm
Posts: 78
Thanks both.

I thought the approach is more effective and it still deals with an object.


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.