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

Darryl Miles darryl-mailinglists at netbauds.net
Thu Oct 30 15:21:44 EDT 2008

Ahead of my claim is that an empty Junction in Criteria API is really a 
programming concern (possibly a programming/usage error).

I understand your point of view of the way you might expect it to work 
if you were creating an SQL query builder and wanted to deal with the 
empty junction situation gracefully.

My view point comes from an empty Junction is a programming error, 
therefore how do we detect this error soonest during development, we do 
that by causing the most havoc by working the opposite way, therefore 
the application should never get through testing.  Now if an empty 
junction is not an error then I'd agree with your logic when using 
Critera API as an SQL query builder since that is the natural way.

I know of situations where the Criteria API application code would look 
elegant and cleaner if there was such an AnnulMode setting to Junctions 
to deal with empty junctions.

Maybe an annul mode of AnnulMode.NATURAL_IF_EMPTY would work the way you 
describe that would make sense to me.  It stays in the query but flips 
the way you describe.

We can always argue over what everyone thinks the default should be (I 
couldn't not care less what the default is, if only I can set AnnulMode) 
I just want good API design that will cope with common situations I have 

As for the you know of a real app that crashed etc... thats your testing 
departments and QAs problem.

As for you not wishing to use such and such software, well for a start I 
am in no way a HIB committer, I have experience with just this problem 
with Junctions and Criteria API myself.

Line 76 I guess:



More information about the hibernate-dev mailing list