[hibernate-dev] Hibernate Disjunction Criteria broken: returns true for empty list of criteria

William Pugh pwilliam at google.com
Thu Oct 30 13:54:40 EDT 2008


>
> Yes the whole point of all WHERE clauses is to filter/reduce the available
> data-set.  I see this point of view but...

No, the point of a where clause it to give you the data you want.

A query that gives me no results back is far more useful and common
than a query that materializes my entire database in memory.

I know of a real application that had a serious problem because this
bug in hibernate caused the system to crash because it swamped memory.

The standard logic for handling an disjunction is:

    if any clause is true, return true
    otherwise, return false

Having the logic the way it is currently implemented introduces all
sorts of logical discontinuities in Hibernate.

For example, Or( X, Or(Y | Z)) != Or( Or(X, Y) | Z), using | to
represent list concatenation.

Frankly, the claim that Or of the empty list should return true isn't
credible. To be blunt, I don't want to use any software written by
someone who believes that.

> AND is generally used to decrease the size of the returned data-set.  So to
> capture the most bugs we return less data than expected "AND 1=0".

Also bogus. The standard logic for handling a conjunction is:

    if any clause is false return false
    otherwise, return true

Bill Pugh
My personal opinion, not that of any of my employers



More information about the hibernate-dev mailing list