-->
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.  [ 3 posts ] 
Author Message
 Post subject: Selecting parent object from criteria of IList of parent obj
PostPosted: Tue Jul 31, 2007 5:29 pm 
Newbie

Joined: Mon Apr 02, 2007 9:56 am
Posts: 11
Hi,
I am trying to write a hquery for the following object:

Code:
class myobject
{
  string myObjectName;
  IList<tomatoe> tomatoes;

}

class tomatoe
{
  int Id;
  string Name;
  TomatoeType tT;

}


I need to bring all myObjectName from myObject(s) where tomatoe.id=3 that is in the tomatoes IList.

Any help is appreciated
Thank you,
E


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 01, 2007 1:32 pm 
Regular
Regular

Joined: Fri Jan 27, 2006 2:32 pm
Posts: 102
Location: California, USA
Try this. It doesn't use a specific ID number, but an actual object. You should be able to adapt it to your needs:

Code:
select obj from myobject obj where :TomatoObject = some elements(obj.tomatoes)


This uses a named parameter for the object reference.

I haven't tried it, but you might be able to use an ID number by doing something like this:

Code:
select obj from myobject obj where :TomatoObjectID = some elements(obj.tomatoes.Id)


^^^ Never tried that but it **might** work.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 03, 2007 3:54 pm 
Newbie

Joined: Mon Apr 02, 2007 9:56 am
Posts: 11
Thank you Pelton,

I actually solved the problem like this:

Code:

select obj from myobject obj where obj.id in (select T.obj.Id from tomatoe T where tT.id = : tomatoTypeId)


The resource where I got this info said that HQL like this may not work in all databases. I am only concern that works with Oracle (which I do not know). For now it works in SQL.

Thanks again


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