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 ... )
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.