-->
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: setting a collection attribute in HQL where clause
PostPosted: Mon Sep 27, 2004 7:56 pm 
Newbie

Joined: Mon Sep 27, 2004 6:52 pm
Posts: 6
Location: US
I am new to this framework. So, pls help me in solving the problem stated below.

I have got the following tables:
Trade having 1 to many association with Product
Product having 1 to many association with Voyage

I am interested in finding all the voyages present in a product for a particular trade. I would like to reduce the size of the resultset by streamlining the query. In Voyage I have the column ship_id. So, while making the query i want to load only the data pertaining to a particular ship. Is there any way other than making change in the where clause of map collection in the mapping document, so that the entire data is not loaded into memory?
Also, i am using map collection. I can not use Arrays or list as my table do not have numeric indices.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 28, 2004 3:01 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
select product.voyages
from Product product
where product.trade = ?
and product = ...

you may need bidirectionnal association.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 28, 2004 7:41 pm 
Newbie

Joined: Mon Sep 27, 2004 6:52 pm
Posts: 6
Location: US
I am using bidirectional mapping. Each Trade object has a Map of product and each Product object has a Map of voyage. Product has a many to one association with Trade and Voyage has many to one with Product.

I am looking forward to change the following SQL query to HQL:

select * from trade t,product p,voyage v where t.trade_id=p.trade_id and p.itinerary_code=v.itinerary_code and t.trade_id='T1' and p.type='P1' and v.ship_id='SP'

Pls help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 01, 2004 6:24 pm 
Newbie

Joined: Mon Sep 27, 2004 6:52 pm
Posts: 6
Location: US
No one to help :( :(

i was working with it... and then used the follwoing HQL:

select distinct prod from Trade trade inner join trade.product prod inner join prod.voyage voy where voy.resShipId=:resShipId and voy.resDepartDate >= sysdate and prod.resType=:resType and trade.resTradeId=:tradeId

Ofcourse it is returning me what i wanted, but in Product object I am getting the map of the entire voyage list and condition voy.resDepartDate >= sysdate is not satisfied.


sanjib wrote:
I am using bidirectional mapping. Each Trade object has a Map of product and each Product object has a Map of voyage. Product has a many to one association with Trade and Voyage has many to one with Product.

I am looking forward to change the following SQL query to HQL:

select * from trade t,product p,voyage v where t.trade_id=p.trade_id and p.itinerary_code=v.itinerary_code and t.trade_id='T1' and p.type='P1' and v.ship_id='SP'

Pls help.


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.