-->
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: equi joins using Criteria
PostPosted: Tue Jan 30, 2007 9:34 am 
Newbie

Joined: Tue Jan 30, 2007 8:43 am
Posts: 5
Location: India
Hi,

How do I write a query using Criteria class for the below SQL

SELECT * FROM SUPPLIER_MAST supp,
SUPPLIER_CONTACT_LIST cntct,
SUPPLIER_CONTACT_ADDRESS address,
LOCATION location,
WHERE
supp.supplier_id = cntct.supplier_id
and cntct.supplier_contact_list_id = address.supplier_contact_list_id
and address.location_id=location.location_id
and location.city ='NY',
and location.state_or_prov_desc = 'AK',
and location.country_desc = 'US'
and location.zip_or_postal_code = 5050


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 30, 2007 9:46 am 
Newbie

Joined: Tue Jan 30, 2007 8:43 am
Posts: 5
Location: India
do i have anyother alternative for solving the above query
plz let me know if my query is not clear..

Regards,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 3:21 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi sureshmilo,

I would suggest to use HQl.By using Criteria You can able to fire same query but Return object does not have your expected value or will return null. Because Return state of object always consistent with DB .Lets say one Parent has three children then if u are applying any criteria on child,If any child matches it would return parent with 3 child. If not would return null.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 6:41 am 
Newbie

Joined: Tue Jan 30, 2007 8:43 am
Posts: 5
Location: India
Hi,

even i had started with HQL

I am using Query class

if my return row has data from different tables how do i get that into a java bean

say for example my query is :
select a.id b.name from sutdent a , studentDetails b
where a.id = b.id
and a.id = 10

by query.list() method i get an arraylist

will i be able to typecast (Details)query.list.get(0)?
where Details class has getter setter for id and name

or

do i need to do sometype of mapping for that return bean?

thx
Suresh


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.