Ok, here are some tables.

CREATE TABLE Foo (
  id int PRIMARY KEY,
  color VARCHAR,
  barId int,
  FOREIGN KEY (barId) REFERENCES Bar
)

CREATE TABLE Bar (
  id int PRIMARY KEY,
  someValue VARCHAR
)

In the mapping there is a <many-to-one> association between Foo and Bar.

Here is a query in HQL:
SELECT foo FROM foo IN CLASS Foo
WHERE foo.color='green' AND (foo.bar=? OR foo.bar.someValue='happy')

What I mean:
Give me all the green foos that have a link to a happy bar or have a link
to a bar that I provide.

The generated SQL-Code produces the cartesian product between Foo and Bar:
SELECT ... FROM Foo foo, Bar sim0
WHERE (foo.color='green')AND((foo.barId=[id of the bar that I provided] )
OR(sim0_.someValue='happy'  and foo.barId=sim0_.id))

Thats what I want:
SELECT ... FROM Foo foo, Bar sim0
WHERE (foo.color='green')AND((foo.barId=[id of the bar that I provided] )
OR(sim0_.someValue='happy')) AND foo.barId=sim0_.id

Any comments?

ciao
 Sven



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to