> 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') > [snip] > 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?
Hmmmmmm, yeah this is very interesting. I certainly wouldn't characterize it as a "bug" (because the generated SQL is exactly what is intended) but I agree it *is* counterintuitive that FROM foo IN CLASS Foo WHERE foo.color='green' OR foo.bar.baz='somethingThatBazIsNeverEqualTo' and FROM foo IN CLASS Foo WHERE foo.color='green' would have *completely* different result sets. Note that with the addition of a DISTINCT clause, they give the same results, ie. SELECT DISTINCT foo FROM foo IN CLASS Foo WHERE foo.color='green' OR foo.bar.baz='somethingThatBazIsNeverEqualTo' and SELECT DISTINCT foo FROM foo IN CLASS Foo WHERE foo.color='green' have exactly the same result sets. On the other hand, your proposal is no good either, since it does not return green Foos with bar=null. So it seems to me like both are imperfect, but existing functionality is better, because we can force what we mean by adding "distinct". I'm sure an OODB could handle this much more elegantly but for a relational database, I don't think we can do much better..... ********** CAUTION - Disclaimer ********** This message may contain privileged and confidential information. If you are not the intended recipient of this message (or responsible for delivery of the message to such person) you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. If you have received this message in error, you should destroy it and kindly notify the sender by reply e-mail. Please advise immediately if you or your employer do not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Expert Information Services Pty Ltd ("The Company") shall be understood as neither given nor endorsed by it. The Company advises that this e-mail and any attached files should be scanned to detect viruses. The Company accepts no liability for loss or damage (whether caused by negligence or not) resulting from the use of any attached files. **EIS******** End of Disclaimer ********** ------------------------------------------------------- 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