Last active
April 26, 2017 14:13
-
-
Save gregorydickson/1c5f3053eafda1a9da498545206c98f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List results = criteria.listDistinct () { | |
createAlias('samples','s',CriteriaSpecification.LEFT_JOIN) | |
createAlias('s.sampleRequests', 'sr', CriteriaSpecification.LEFT_JOIN) | |
or { | |
isNull('s.id') | |
sizeEq('s.sampleRequests', 0) | |
//Needs to be any samples available, not all samples available. | |
// In other words check all items in the collection and if they all meet | |
// the condition then exclude | |
and{ | |
not{ | |
between('sr.bookingStartDate', availableFrom, availableTo) | |
} | |
not{ | |
between('sr.bookingEndDate', availableFrom, availableTo) | |
} | |
'in' ('sr.requestStatusBrand',['Approved','Picked Up','Returning']) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment