• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Criteria Issue

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have two tables say X and Y, with a join table X_Y. now there is a Z table which can be associated with X and Y tables somehow (with a foreign key).

But my issue is that I have a U table which is not associated with X and Y or Z for that matter in any ways. How do I :
Write query for such a scenario? (meaning how will hibernate be able to generate where U.id = "SOME_ID" for a query on X and y); to illustrate heres what i mean :

Select x_.Name,
y_.name,
from X x_
LEFT OUTER JOIN
X_Y ASSOCIATE_
ON ASSOCIATE_.ID = x_.ID
LEFT OUTER JOIN
Y y_
ON ASSOCIATE_.ID = y_.ID
WHERE U.ID = ?

Any kind of help (you can tell me the SQL too ... )

Rick.
[ April 03, 2008: Message edited by: Anirudh Vyas ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually it looks like you have it already. When you query the data you will have to add it to the Where clause. So in Criteria add a Restriction, for Query use the object in the Where clause, and in SQLQuery objects exactly how you wrote it in your post.

Mark
 
Anirudh Vyas
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey ... yea i was able to sort that out; added a simple restriction (d-oh, i was full of it last night because of work and all)

Thanks for your help.

Regards
Vyas, Anirudh
 
reply
    Bookmark Topic Watch Topic
  • New Topic