-->
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: Can a query load only Child and no Parent
PostPosted: Fri Apr 16, 2004 8:06 pm 
Beginner
Beginner

Joined: Sat Nov 22, 2003 3:54 pm
Posts: 42
Hi,

If i simply want to load only the Child object and no Parent object, how to do that?

There are two class test(Parent) and testChild(Child). There is one to many relationship between test and testChild and many to one from testChild to test.

If i simply want to load testChild without loading test(parent), is it possible? I dont want to define each attributes of the testChild in the HQL ?

Any advice would be really appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 17, 2004 4:05 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
select elements(parent.child) from Parent as parent

or

select child from Child as child where child.parent.id = ?


for example


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 17, 2004 12:11 pm 
Beginner
Beginner

Joined: Sat Nov 22, 2003 3:54 pm
Posts: 42
Thanks delpouve.

But the problem is that if i have only some value related to child on which i want to execute a query, i dont have a value of any parent.id?

Is it possible to load child that way without loading the parent?

Thnaks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 17, 2004 12:13 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
if you're querying on the child, there is no reason why the parent should be loaded, just proxy the "to-one" associations you don't want to be loaded as described in the doc.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2004 1:05 am 
Beginner
Beginner

Joined: Sat Nov 22, 2003 3:54 pm
Posts: 42
Thanks delpouve.
It works.


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.